Place barcodes and matrix codes

pdfToolbox supports the placement of both 1D barcodes (e.g., EAN-13) and 2D codes (e.g., QR codes, Data Matrix codes) on PDF pages. With support for over 100 barcode types, it covers all commonly used codes in practice.

A complete list of supported barcodes and matrix codes can be found in this article: List of supported barcodes and matrix codes.

The "Place barcode" Fixup

Screenshot that shows all the availible setting options for thScreenshot showing all available settings for the "Place Barcode" fixupe "Place barcode" fixup
  1. Type and expected value:  A list of supported barcodes and matrix codes, along with examples of the expected value for each code, can be found here)
  2. Font settings: The "Method" option allows you to define fonts using: Font family, Web font or Font from library. When selecting "Fonts from Library", fonts can be imported from the system.
  3. Position settings: Defines the barcodes position and dimensions. The mouse selection tool can be used to visually select an area on the PDF page.
  4. Option to place the barcode on a new layer.
  5. Color settings for the barcode.
  6. Color settings for the barcode background.
  7. A preflight check can be set as a filter to specify which pages the barcode should be applied to.
  8. To create multiple barcodes within the Fixup, use the "+" button. Alternatively, the "Duplicate Setting" button can be used to copy an existing set of configured parameters.

Advanced settings for barcode and matrix codes

Earliest version with full support for  specifying advanced settings for barcode and matrix codes is pdfToolbox 16

The "Place barcode" Fixup provides various options for barcode creation, such as setting the barcode and background colors, adjusting font settings, and more. However, additional advanced parameters allow further customization of the barcode appearance. These parameters can be used, for example, to add a rectangular matrix code or to remove the text from an EAN-13 code.

The "Advanced settings" tab provides a multiline input field for adding JSON-based key-value pairs to specify additional advanced parameters.

Note: Many of these parameters are symbology-specific, and a good understanding of how a given barcode or matrix code works is required in order to successfully use the parameters.

  1. Clicking the info button opens a dialog showing all supported parameters for the barcode object that can be added (a list of these parameters can also be found in this article: Extended list of parameters for the barcode object)
Screenshot showing the Advanced Settings tap with a multiline input field and an info button at the top right
  1. Each parameter includes a short description, the expected data type, and a list of possible values.
  2. After inserting a parameter from the list, its key and default value are automatically inserted, allowing for easy customization.
Screenshot showing the Diloge window with all available parameters for the barcodes

Multiple advanced parameters can be defined for a barcode.

Note: Advanced settings are always applied after the barcode is generated. This means e.g. that if a 90° rotation is set in the "Place Barcode" tab and a "rotation" key ("rotation" : "90") is also specified in the "Advanced settings", the barcode will be placed on the PDF with a total rotation of 180°.

Note: For each barcode defined in the "Place Barcode" section of the Fixup, a separate advanced setting must be created.

Screenshot showing an example where two advanced settings are specified

Predefined Fixup to place EAN 13 barcode

pdfToolbox already comes with a predefined Fixup that allows you to place an EAN-13 barcode with a custom value on a PDF page.

Screenshot showing the predefined fixup "Place EAN 13 barcode with specified value"
  1. Go to the predefined pdfToolbox Library "Shapes, Variables, JavaScript, Place content".
  2. Go to the "Fixups" section.
  3. Enter "EAN" in the search box to restrict the list of Fixups shown to those containing the term "EAN".
  4. Select the Fixup named "Place EAN 13 barcode with specified value"
  5. Click "Fix" to place the EAN 13 barcode.

Optional: specify the value of the EAN 13 barcode to be placed

A dialog window will appear where you can enter the value for the EAN 13 barcode that will be placed in the file. If no entry is given, the default value will be used.

Important: The value entered must consist of 12 or 13 digits. If 12 digits are entered, pdfToolbox will automatically calculate the required check digit. If 13 digits are entered, the 13th must be a valid check digit, otherwise the attempt to place the barcode will return an error.

Screenshot showing the ask-at-runtime dialog where you can specify a value for the barcode

In order to adapt the Fixup to your own requirements, it is advisable to create a copy of the existing Fixup and make the required changes to this copy.