Table of Contents

Class QRCode

Namespace
PDFjet.NET
Assembly
PDFjet.dll

Used to create 2D QR Code barcodes. Leave a quiet zone, blank, of 4 modules all around the code, as a scanner needs it. Please see Example_37.

public class QRCode : IDrawable
Inheritance
QRCode
Implements
Inherited Members

Constructors

QRCode(string, ErrorCorrectionLevel)

Used to create 2D QR Code barcodes. The string is encoded in UTF-8, and the symbol is the smallest that holds it, from version 4, 33 by 33 modules, to version 40, 177 by 177 modules. At version 40 it holds up to 2,953 bytes at level L, 2,331 at M, 1,663 at Q and 1,273 at H, a byte fewer when the string is not all ASCII: it then starts with the ECI that tells the reader the bytes are UTF-8.

public QRCode(string str, ErrorCorrectionLevel errorCorrectionLevel)

Parameters

str string

the string to encode.

errorCorrectionLevel ErrorCorrectionLevel

the desired error correction level.

Exceptions

ArgumentException

If the string does not fit in a version 40 symbol.

Methods

DrawOn(Page)

Draws this barcode on the specified page. The dark modules next to each other in a row are filled as one rectangle, and the pen and the brush of the page are as they were after it.

public float[] DrawOn(Page page)

Parameters

page Page

the page to draw on.

Returns

float[]

x and y coordinates of the bottom right corner of this component.

Fits(string, ErrorCorrectionLevel)

Tells whether the string fits in a QR code at the error correction level, so that a program can refuse a text before it draws, and say why, where the constructor would throw. The limit is in UTF-8 bytes, not characters: at level M, 2,331 bytes of ASCII, or 2,330 with the ECI of a string that is not all ASCII, so 776 euro signs, 3 bytes each, fit, and 777 do not. A level that is not one fits nothing.

public static bool Fits(string str, ErrorCorrectionLevel errorCorrectionLevel)

Parameters

str string

the string to encode.

errorCorrectionLevel ErrorCorrectionLevel

the error correction level.

Returns

bool

true if the constructor would make a QR code of the string; false for a level that is not one of L, M, Q or H.

GetModules()

Returns the modules of the QR code: true for dark and false for light modules.

public bool?[][] GetModules()

Returns

bool?[][]

the modules.

SetAltDescription(string)

Sets what the QR code says, such as the web address it carries, for a screen reader: a tagged document, PDF/UA or a PDF/A of level A, then has the QR code as a figure of that description. Without one, it is decoration, which a screen reader skips.

public QRCode SetAltDescription(string altDescription)

Parameters

altDescription string

the description.

Returns

QRCode

this QRCode object.

SetLocation(float, float)

Sets the location where this barcode will be drawn on the page.

public QRCode SetLocation(float x, float y)

Parameters

x float

the x coordinate of the top left corner of the barcode.

y float

the y coordinate of the top left corner of the barcode.

Returns

QRCode

this QRCode object.

SetModuleColor(int)

Sets the color of the QR code. It is black unless set. Color.transparent leaves it unchanged. Use a dark color on a light background, as navy, dark green or dark brown: most scanners read with red light, in which red, orange and yellow modules look white.

public QRCode SetModuleColor(int color)

Parameters

color int

the color as a 0xRRGGBB value.

Returns

QRCode

this QRCode object.

SetModuleLength(float)

Sets the module length of this barcode. The default value is 2.0f

public QRCode SetModuleLength(float moduleLength)

Parameters

moduleLength float

the specified module length.

Returns

QRCode

this QRCode object.