> For the complete documentation index, see [llms.txt](https://docs.yansalabs.com/pdf-generator/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yansalabs.com/pdf-generator/technical-docs/adding-qr-barcodes-to-pdfs/how-to-use-barcode-content-in-pdf-templates.md).

# How-to Use Barcode Content in PDF Templates

Creating pages of barcode labels for printing is a great way to consolidate your asset management workflow into ServiceNow, printing custom labels for laptops and other devices in your organization.

See below for a step-by-step example of how to create your own barcode labels.

### Create your QR/Barcode Content

1. Ensure you have Yansa's [**Barcode & QR Code Generator**](https://docs.yansalabs.com/barcode-and-qr-code-generator/) app installed
2. Navigate to **Barcode & QR Code Generator -> Barcode Generators** and click 'New' to create a new [Barcode Generator](https://docs.yansalabs.com/barcode-and-qr-code-generator/technical-docs/building-a-barcode-label/barcode-generator).

<figure><img src="/files/N93KARNcYYnjwTqw6qOG" alt=""><figcaption><p>Barcode Generator w/ Barcode Part Related List</p></figcaption></figure>

3. After setting the basic settings of the [Barcode Generator](https://docs.yansalabs.com/barcode-and-qr-code-generator/technical-docs/building-a-barcode-label/barcode-generator) and saving the record, you'll need to create a new [Barcode Part](https://docs.yansalabs.com/barcode-and-qr-code-generator/technical-docs/building-a-barcode-label/barcode-parts) via the related list at bottom.

<figure><img src="/files/2WhMqE12p7LjkplZPf3w" alt=""><figcaption><p>Barcode Part</p></figcaption></figure>

{% hint style="info" %}
When creating a **Barcode Generator** for use in a PDF Template, we recommend making it as *simple as possible* - a single **Barcode Part** that is the barcode or QR code component with no added borders or padding. You can add additional text/HTML content within your PDF Template.
{% endhint %}

### Create your Label Template

1. Ensure you have Yansa's [**PDF Generator**](https://docs.yansalabs.com/pdf-generator/) app installed
2. Navigate to **Yansa PDF Generator -> Label Templates** and click 'New' to create a new [Label Template](/pdf-generator/technical-docs/building-a-pdf-template/creating-labels/label-templates.md).

{% hint style="warning" %}
The 'Test record' table in your **Barcode Generator** and the 'Source table' in your **HTML to PDF Merge Template** or **Label Template** should always be the same when using a Barcode Generator within a PDF template. This insures that dynamic data in both the Barcode Generator and PDF template will be pulled from the correct source.
{% endhint %}

<figure><img src="/files/2dlnKlmWrVJIuEDz4w0P" alt=""><figcaption><p>Label Template w/ Merge Maps Related List</p></figcaption></figure>

3. After setting the basic settings of the [Label Template](/pdf-generator/technical-docs/building-a-pdf-template/creating-labels/label-templates.md) and saving the record, you'll need to create new [Merge Maps](/pdf-generator/technical-docs/building-a-pdf-template/merge-maps.md) via the related list at bottom. For the QR/Barcode content, that Merge Map will look similar to the example below. Note how the Merge Map is embedded in the 'Template HTML' of the Label Template above.

<figure><img src="/files/iWcymLe9IjB5TNEkK7J3" alt=""><figcaption><p>QR/Barcode Merge Map</p></figcaption></figure>

### Generate your Barcode Labels

1. Use the **Generate PDF** button in the Label Template header to create your labels. First, you'll see the 'un-merged' version of your labels.

{% hint style="info" %}
To make it simple for your users to generate PDFs where & when they need, you can [customize & place the **Generate PDF** button & UI on any form](/pdf-generator/technical-docs/the-generate-pdf-wizard/pdf-wizard-standard-forms.md).

Also, you can automate the generation of PDFs via [Flow Action](/pdf-generator/technical-docs/generating-a-pdf-document/create-from-flow-action.md) or [Script](/pdf-generator/technical-docs/generating-a-pdf-document/create-from-script.md).
{% endhint %}

<figure><img src="/files/F8GtYGQEaTFM3eGtLG0N" alt=""><figcaption><p>Un-Merged Labels</p></figcaption></figure>

2. Click Next and select a [Data Source](/pdf-generator/technical-docs/building-a-pdf-template/data-sources.md) to merge data into your labels.

<figure><img src="/files/GHxiUopPJyJFRSZN9395" alt=""><figcaption><p>Merged Labels</p></figcaption></figure>

{% hint style="warning" %}
Generating barcodes & QR codes server-side takes time! When generating large numbers of labels, it can take several seconds or minutes to complete.

Instance memory can also affect ServiceNow's ability to render many labels. QR Codes, in particular, generate a large amount of HTML to render. Smaller instances or larger batches may result in failure to render. In practice, we can reliably generate approximately 500 QR code labels in a single batch.

It may be helpful to create multiple separate [**Data Sources**](/pdf-generator/technical-docs/building-a-pdf-template/data-sources.md) to break the process into parts.

Future label generation runs for the same data source will complete faster due to caching.
{% endhint %}

3. Finally, click next and save/attach your label PDF to your desired location!
