Barcodes

Category : Technical Examples

Barcodes of different formats can be inserted into documents.

Docmosis provides Code 39, Code 128 and ITF 14 formats.


Template
Data Files
Output Files
All Files as a ZIP

This example explained

1) Inserting Barcodes

Inserting barcodes with Docmosis uses a technique similar to inserting images, except that an optional extra field can be used to specify the attributes of the barcode.

An image in the template can be marked with a name, eg "img_barcode1". This image placeholder now determines the size and position of the barcode in the finished document.

In Microsoft Word a Bookmark is assigned to it to identify which piece of data will be used for the value of the barcode. In LibreOffice the name of the image is used instead.

Docmosis will use the data to generate and insert the barcode in place of the image.


2) Barcode Attributes

In addition, a "barcode field" may be defined somewhere in the template to set additional attributes for the barcode. This barcode field links the barcode to a barcode format, for example, the following barcode field sets "barcode1" to be a "code 39" format:

      <<barcode:barcode1:code39>>

The barcode field can exist anywhere in the template. When the document is rendered, the value for "barcode1" will be looked up and used to create the barcode.

The special field <<barcode: … >> will be removed from the final document.


3) Default Values

The barcode field in the template can specify default settings for the barcode, including the value, resolution and more. The format and the value are the most common, so they can be specified as follows:  

    <<barcode:name:value:format>>

    eg: <<barcode:barcode1:ABC123:code128>>

specifies barcode1 to have a value of ABC123 and be of type code 128. These settings will be overridden in the data if they are provided.

Other settings such as the resolution can be specified either as a default in the template-field or via the data values. These other settings are specified as key=value pairs. For example, the resolution (dpi) can be specified by:

    <<barcode:barcode1:code128:dpi=1200>>

such a setting (increased resolution) might be required for a small sized barcode.