Integrating a QR code generation functionality into an advanced PDF template.

The below provided HTML code is aimed at integrating a QR code generation functionality into an advanced PDF template.

<td border="1.5" style="width:40%; border-color: rgb(0,0,0);margin-left:5px;padding-left:0px;padding-right:0px;padding-top:0px;padding-bottom:0px;">
                            <#if record.custbody_if_parent_waybill_no?has_content>
                              <barcode align= "center" codetype="qrcode" showtext="true" width="100%" height="100%" value="${record.custbody_if_parent_waybill_no}"/></#if></td>

Condition for Barcode Generation (<#if record.custbody_if_parent_waybill_no?has_content>):

  • This line initiates a conditional check using the FreeMarker templating language. It verifies if the “custbody_if_parent_waybill_no” field of a record has content.

Barcode Generation (<barcode>):

If the condition is met (i.e., “custbody_if_parent_waybill_no” has content), a QR code is generated using the <barcode> tag.

The QR code is aligned to the center (align="center"), has a type of “qrcode” (codetype="qrcode"), displays text (showtext="true"), and spans the entire width and height of the cell (width="100%" and height="100%").The value of the QR code is dynamically populated with the content from the “custbody_if_parent_waybill_no” field of the record (value="${record.custbody_if_parent_waybill_no}").

Overall, this code facilitates the automatic creation of a QR code within a PDF template based on the content of a specific field in a given record.

The generated QR code will be like this.

Leave a comment

Your email address will not be published. Required fields are marked *