THPDFPage.DrawQRCode Method

Encodes Data as an ISO/IEC 18004 QR Code (Model 2) and paints it on the page as a grid of filled squares. The encoder chooses the smallest version (1 to 40) capable of holding the data at the requested error correction level, selects numeric, alphanumeric or byte mode of its own accord, and settles on the mask with the lowest penalty score

Declaration

function DrawQRCode(const Data: AnsiString; X, Y: Single; ModuleSize: Single= 2; ECLevel: THPDFQRECLevel= qrM; Color: TColor= clBlack): Integer;

Unit

HPDFDoc

Parameters

NamePurpose
DataThe bytes to encode. Digits alone use numeric mode; text confined to the upper-case alphanumeric set (0-9 A-Z, space and $%*+-./:) uses alphanumeric mode; anything else — lower-case letters included — is stored byte for byte. Pass UTF-8 bytes for non-ASCII text
XLeft-hand edge of the symbol in page coordinates
YTop edge of the symbol in page coordinates
ModuleSizeSide length of a single module, in drawing units (points when Resolution stays at its default of 72); must be greater than zero
ECLevelError correction level: qrL (roughly 7 % recovery), qrM (15 %), qrQ (25 %) or qrH (30 %). Higher levels call for a larger symbol to carry the same data
ColorFill colour of the dark modules. Light modules are not painted, so site the symbol on a light background

Return value

The number of modules along one side of the symbol (21 for version 1 through 177 for version 40), so the symbol spans Result * ModuleSize drawing units in each direction. Gives 0 and draws nothing when Data is empty, ModuleSize is not positive, or the data will not fit a version 40 symbol at the chosen level

Usage notes

Related APIs