Class QRCode
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
strstringthe string to encode.
errorCorrectionLevelErrorCorrectionLevelthe 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
pagePagethe 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
strstringthe string to encode.
errorCorrectionLevelErrorCorrectionLevelthe 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
altDescriptionstringthe 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
xfloatthe x coordinate of the top left corner of the barcode.
yfloatthe 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
colorintthe 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
moduleLengthfloatthe specified module length.
Returns
- QRCode
this QRCode object.