Draws a two-dimensional barcode on a page. Currently, four types are supported: PDF417, Data Matrix, QR Code and Aztec.
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. Aztec is supported as of Version 3.4.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), 3 (QR Code) and 4 (Aztec).
1 by default.
- BarWidth - the width of the narrowest vertical bar (PDF417) or cell (Data Matrix, QR Code, Aztec), 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, QR Code and Aztec barcodes as the cells are always square.
- ErrorLevel - in PDF417, QR Code and Aztec 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.
- In Aztec, the valid values are 1 to 4 (2 by default.)
- 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, QR Code and Aztec 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 and Aztec.
- 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 and Aztec.
- 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.)
In Aztec, the valid values are 0 (default, automatic size determination) and 1 to 36. See Section 12.1.5.4
for the table of valid values.
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.
- Width, Height - in PDF417 bacodes, specify the overall width and height of the barcode symbol in user units, including the quiet zone (described below.)
Both parameters must be specified to have an effect, i.e. if one is omitted, the other is ignored. If both of these parameters
are specified, BarWidth and AspectRatio are ignored. Requires Version 3.2.0.1+.
- QZH, QZV - in PDF417 bacodes, specify the "quiet zone" space margins in user units on the left/right and top/bottom sides of the barcode, respectively.
0 by default. These parameters are only used if the Width/Height parameters are specified. Requires Version 3.2.0.1+.
- Binary - in PDF417 bacodes, if set to true, forces the byte (or binary) compression mode in which each codeword represents 1.2 bytes of information
The default text compression mode encodes (roughly) 2 characters per codeword. False by default. Requires Version 3.2.0.1+.
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.