In DocuGenerate, you can go beyond text and images by incorporating QR codes and barcodes into your templates. These elements enable you to enhance your documents with additional information or automate processes efficiently.
To add a QR code to your template, use a tag starting with the %
character, like for adding images, followed by the qrcode
filter, as shown below. Also, please make sure you enable the enhanced syntax for your template.
[%url | qrcode]
[%url | qrcode:'width':'height']
The url
parameter specifies the URL or text that you want to encode into the QR code. Optionally, you can define the width
and height
parameters to customize the dimensions of the QR code, similar to resizing images.
Here’s an example template that includes a QR code:
Scan the QR code to visit our website
[%website | qrcode:200:'auto']
The JSON data used to generate the document should contain a website
field, which points to the URL of the website. Ensure that the JSON key doesn’t include the %
character, as it needs to be "website"
and not "%website"
:
[{
"website": "https://www.docugenerate.com"
}]
When the template is processed to generate the document using the provided data, the [%website | qrcode:200:'auto']
tag is replaced with a QR code containing the URL of your website. The result will look like this:
Similarly, you can add barcodes to your templates using a tag starting with the %
character, followed by the barcode
filter, as shown below. Please make sure you have enabled the enhanced syntax for your template before generating any documents.
[%text | barcode]
[%text | barcode:'width':'height']
The text
parameter specifies the value that you want to encode into the barcode. Optionally, you can define the width
and height
parameters to customize the dimensions of the barcode, similar to resizing images.
Here’s an example template that includes a barcode:
Product code
[%product_code| barcode:'auto':150]
The JSON data contains a product_code
field, which is the value to be encoded in the barcode. Ensure that the JSON key doesn’t include the %
character, as it needs to be "product_code"
and not "%product_code"
:
[{
"product_code": "1234567890"
}]
When the template is processed to generate the document using the provided data, the [%product_code| barcode:'auto':150]
tag is replaced with a barcode containing the specified value. The result will look like this: