Class CodeQR
A QR code (ISO/IEC 18004, model 2), drawn as vector shapes so it stays sharp at any size.
public class CodeQR : MatrixCode
- Inheritance
-
objectCodeQR
- Inherited Members
Remarks
Size is the whole symbol including the QuietZone. The symbol is square; when the size is not, the symbol is centred in it.
Text of digits only is encoded in the numeric mode, text of digits, upper-case letters and
$%*+-./: in the alphanumeric mode, and any other text in the byte mode: ASCII as is, everything
else as UTF-8.
Draw it with XGraphics.DrawMatrixCode, or in MigraDoc with a Barcode of type QRCode.
Constructors
- CodeQR(string)
Initializes a new QR code for the text, with error correction level M. Set Size before drawing it.
- CodeQR(string, XSize)
Initializes a new QR code for the text and size, with error correction level M.
- CodeQR(string, XSize, QRErrorCorrectionLevel)
Initializes a new QR code for the text, size and error correction level.
Properties
- ErrorCorrectionLevel
Gets or sets the error correction level. The default is M.
- QuietZone
Gets or sets the width of the light margin around the symbol, in modules. The standard asks for 4, the default. Set it to 0 when the surrounding layout already leaves that space light. The quiet zone is not painted: it shows whatever lies beneath, which should be light.
- Utf8Eci
Gets or sets whether text that is not ASCII is marked as UTF-8 with an ECI (extended channel interpretation) designator, as the standard asks. The default is true. Some payment and banking apps expect UTF-8 without the marker; set it to false for them.
- Version
Gets or sets the version (1 to 40), which sets the number of modules: 21 for version 1, 4 more for each further version. 0, the default, picks the smallest version the text fits in. Drawing throws when the text does not fit the version set here.
Methods
- CheckCode(string)
Any text that is not empty can be encoded; its length is checked when the code is drawn.
- GetModules()
Encodes the text and returns the symbol's modules without the quiet zone, indexed [row, column], true for dark. The array is a new copy on every call.
- Render(XGraphics, XBrush, XPoint)
Renders the QR code: the dark modules of each row, merged into runs, as one filled path.