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 picks the smallest version (1 to 40) that holds the data at the requested error correction level, chooses numeric, alphanumeric or byte mode automatically and selects 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
DataBytes to encode. Digits only use numeric mode, text limited to the upper-case alphanumeric set (0-9 A-Z, space and $%*+-./:) uses alphanumeric mode, and anything else, including lower-case letters, is stored byte for byte. Pass UTF-8 bytes for non-ASCII text
XLeft edge of the symbol in page coordinates
YTop edge of the symbol in page coordinates
ModuleSizeSide length of one module, in drawing units (points at the default Resolution of 72). Must be greater than zero
ECLevelError correction level: qrL (about 7 % recovery), qrM (15 %), qrQ (25 %) or qrH (30 %). Higher levels need a larger symbol for the same data
ColorFill color of the dark modules. Light modules are not painted, so place the symbol on a light background

Return value

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

Usage notes

Related APIs