Draws a two-dimensional barcode on a page. Currently, three types are supported: PDF417, Data Matrix and QR Code.
Returns various properties of the barcode symbol just drawn.
Introduced in Version 1.8. QR Code is supported as of version 2.0.0.7.
TextData specifies the data
to be encoded as a barcode.
Param is a PdfParam object
or parameter string specifying the following barcode properties:
- X, Y - the coordinates of the lower-left corner of the barcode symbol on the page.
These are the only required parameters.
- Type - specifies the barcode type. Valid values are 1 (PDF417), 2 (Data Matrix) and 3 (QR Code.)
1 by default.
- BarWidth - the width of the narrowest vertical bar (PDF417) or cell (Data Matrix, QR Code), in user units. 1 by default.
- AspectRatio - in PDF417 barcodes, the ratio of the row height to the narrowest bar width. 2 by default.
Ignored in Data Matrix and QR Code barcodes as the cells are always square.
- ErrorLevel - in PDF417 and QR Code barcodes, controls the amount of error correction information in the symbol. The higher this number is,
the more resistant to damage (and larger in size) the symbol gets.
- In PDF417, the valid values are 0 to 8.
The value of 0 means no error correction.
If this parameter is not specified at all, the error level is computed automatically based on
the data size according to the standard PDF417 specifications.
- In QR Code, the valid values are 0 to 3, 0 (default) being the lowest error correction level.
- This parameter is ignored
in Data Matrix barcodes as the error level is always determined automatically.
- Encoding - in Data Matrix barcodes, specifies data encoding. Valid values are: 0 (Automatic), 1 (ASCII), 2 (C40), 3 (Text), 4 (X12), 5 (Edifact) and 6 (Binary).
0 (Automatic) by default. Ignored in PDF417 and QR Code barcodes.
- Columns - in PDF417 barcodes, the symbol will contain at least this number of data columns, provided there is enough data for it.
If not specified, the number of columns is determined automatically.
In Data Matrix barcodes, if this value is specified, Rows must also be specified.
Valid combinations can be found here.
Ignored in QR Code.
- Rows - in PDF417 barcodes, the symbol will contain at least this number of rows, provided there is enough data for it.
If not specified, the number of rows is determined automatically.
In Data Matrix barcodes, if this value is specified, Columns must also be specified.
Valid combinations can be found here.
Ignored in QR Code.
- Version - in QR Code, determines the size of the symbol. 0 by default
which means the size is determined automatically. Other valid values: 1 to 40 (the bigger the number the larger the symbol.)
Ignored in PDF417 and DataMatrix.
- Angle - an angle of counter-clockwise rotation (in degrees) of the barcode around its lower-left corner. 0 by default.
- Color - barcode color, the current fill color by default.
- BgColor - background color (the color of the "white" rectangular area underneath the barcode.) Transparent by default.
Useful to make the barcode background white if the page background is non-white.
- BgMargin - the size (in user units) of the margins around the barcode. 2 x BarWidth by default.
Ignored unless BgColor is specified.
BinaryData specifies binary information to be encoded as a barcode. If this
optional argument is specified, the TextData argument is ignored.
The method returns an instance of the PdfParam object populated with the following
properties of the symbol just rendered: Width, Height, Columns, Rows
and ErrorLevel (the latter is only returned when Type=1.)
For more information about 2D barcodes and the DrawBarcode2D method,
see Section 12.1.5 - Two-Dimensional Barcodes.