This article shows how to add a QR-code to a new or existing document using the QRBarcodeShape.
About QR-Code
A QR code (Quick Response code) is a type of matrix barcode (or two-dimensional code) that consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g., binary, alphanumeric, or Kanji symbols).
Code
Document document = new Document();
Page page = new Page(PageSize.Letter);
document.Pages.Add(page);
QRBarcodeShape qrBarcode = new QRBarcodeShape();
qrBarcode.Width = qrBarcode.Height = 50;
qrBarcode.Transform = new TranslateTransform(72, page.Height - 72 - qrBarcode.Height);
qrBarcode.Data = @"http://www.tallcomponents.com";
page.VisualOverlay.Add(qrBarcode);
using (FileStream file = new FileStream("out.pdf", FileMode.Create, FileAccess.Write))
{
document.Write(file);
} 1 Document document = new Document();
2 Page page = new Page(PageSize.Letter);
3 document.Pages.Add(page);
4
5 QRBarcodeShape qrBarcode = new QRBarcodeShape();
6 qrBarcode.Width = qrBarcode.Height = 50;
7 qrBarcode.Transform = new TranslateTransform(72, page.Height - 72 - qrBarcode.Height);
8 qrBarcode.Data = @"http://www.tallcomponents.com";
9 page.VisualOverlay.Add(qrBarcode);
10
11 using (FileStream file = new FileStream("out.pdf", FileMode.Create, FileAccess.Write))
12 {
13 document.Write(file);
14 }