int32_t __stdcall pdfInsertBarcode(PPDF IPDF, double PosX, double PosY, double Width, double Height, TCellAlign HAlign, TCellAlign VAlign, TPDFBarcode2* Barcode);
function pdfInsertBarcode(const IPDF: PPDF; PosX, PosY, Width, Height: Double; HAlign, VAlign: TCellAlign; var Barcode: TPDFBarcode2): Integer; stdcall;
Purpose. Draw one of 4 built-in 2D-barcode symbologies onto the current page at the given position/box, aligned within that box.
Description. Dispatches on Barcode.BarcodeType: 0=QR Code (DrawQRBarcode, honoring ECLevel/Version/Mask/QuietZone), 1=Data Matrix (DrawDataMatrixBarcode — note this symbology has no error-correction-level or version concept of its own, so ECLevel/ Version/Mask are silently unused for this type), 2=PDF417 (DrawPDF417Barcode — reinterprets Version as the column count, defaulting to 6 if <= 0, and clamps ECLevel into 0..8 as PDF417's own security-level range rather than QR's 4-level scheme), 3=Aztec (DrawAztecBarcode, same as Data Matrix — no ECLevel/Version/Mask effect). Any other BarcodeType value fails outright. In all four cases, Barcode.Text is required (encoded as raw ANSI/UTF-8 bytes — there is no W/wide-string entry point for barcode text), and the box is laid out at PosX/PosY/Width/Height with HAlign/VAlign cell alignment within that box.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
PosX, PosY, Width, Height | Placement box on the current page. |
HAlign, VAlign | Alignment of the barcode symbol within the box. |
Barcode | Populated TPDFBarcode2 (see pdfInitBarcode2); Version/ECLevel/Mask are meaningful only for QR (0) and, differently, PDF417 (2) — ignored for Data Matrix (1) and Aztec (3). |
Return value. 1 on success; 0 if IPDF is invalid, BarcodeType is not 0..3, or the underlying symbol encoder rejected the input (e.g. Text too long/invalid for the chosen symbology and error-correction level).
See also. pdfGetBarcodeDict.
C# (P/Invoke)
public static extern int pdfInsertBarcode(IntPtr IPDF, double PosX, double PosY, double Width, double Height, TCellAlign HAlign, TCellAlign VAlign, ref TPDFBarcode2 Barcode);
Core
pdfInsertBarcode
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.