# PDF Template Editor

The PDF Template Editor provides a visual workflow for designing dynamic documents. You create a template by placing dynamic placeholders onto an uploaded PDF background.

{% hint style="info" %}
The Template Editor works exclusively with the [PDF Template](https://docs.heisenware.com/app-builder/build-backend/functions-library/utilities/pdf-templates) class. When you create a template, an instance is automatically generated within this class, containing the `fillTemplate` function required to populate your document with data.

To see the complete process in action, follow our [step-by-step guide](https://docs.heisenware.com/tutorials/app-templates/automating-pdf-reports).
{% endhint %}

## Creating a PDF template

{% stepper %}
{% step %}

#### Open template mode

Select Template Editing mode from the main toolbar. <img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FDmdlS0ExNMYXw54kEIs3%2Fimage.png?alt=media&#x26;token=51943b41-e2d5-4b35-a4e8-e3fbdf084dda" alt="" data-size="line">&#x20;
{% endstep %}

{% step %}

#### Define properties

Enter a unique name for your template and choose a standard page size (`A4`, `A5`, or `Letter`).
{% endstep %}

{% step %}

#### Generate instance

Click Create Template. This automatically generates the corresponding instance in your logic library.
{% endstep %}
{% endstepper %}

<figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FmYLLfRCiaSfaRyxYtcou%2Fcreate_pdf_template_looped.gif?alt=media&#x26;token=347bced0-3ad2-46ed-a9ec-bc55068cfd0a" alt="" width="563"><figcaption></figcaption></figure>

## Designing the layout

Once your template is created, you need to set up the visual background and place your dynamic fields.

### **Managing pages and backgrounds**

To use an existing document as a layout, you must first upload the pages as separate PDF files to the [Internal File Server](https://docs.heisenware.com/app-builder/build-backend/internal-file-server).

{% stepper %}
{% step %}

#### Add blank pages

Add a blank page for each page of your source document using the Add Page icon (<i class="fa-circle-plus">:circle-plus:</i>).
{% endstep %}

{% step %}

#### Set background

Drag each page file from the Resources panel onto the corresponding blank page. This sets the file as a static background.
{% endstep %}

{% step %}

#### Organize

Right-click a page to open the context menu. Here you can move pages up/down or manage the layering (Bring to Front / Send to Back).
{% endstep %}
{% endstepper %}

{% hint style="danger" %}
Deleting a page (using the Trash icon) is a permanent action that removes the page, its background, and all placeholders on it. It is not currently possible to simply replace the background of an existing page.
{% endhint %}

### **Placing and configuring placeholders**

Placeholders are the dynamic "slots" where your logic will insert data.

{% stepper %}
{% step %}

#### Add placeholder

Click the Text or Image Placeholder icon in the toolbar (<i class="fa-text-size">:text-size:</i>, <i class="fa-image">:image:</i>) then click on the page to place it.
{% endstep %}

{% step %}

#### Assign variable

Select the placeholder and click the gear icon. Provide a variable name (e.g., `firstName`).
{% endstep %}

{% step %}

#### Style

Adjust the font, size, or colors for text, or resize the bounding boxes to define the final content area.
{% endstep %}
{% endstepper %}

{% hint style="info" %}

#### Data Matching&#x20;

The Variable Name you enter (e.g., `invoiceNumber`) must exactly match the key in the data object you provide in your backend logic later. The editor adds the `<>` tags automatically.
{% endhint %}

<figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2F9CVU9xYJTd7TGua0n5lJ%2FUseing_template.png?alt=media&#x26;token=8b5ca603-4630-481e-a00e-3d918429c2e2" alt="" width="563"><figcaption></figcaption></figure>

## Populating the template

To bring your PDF to life, use the [`fillTemplate`](https://docs.heisenware.com/build-backend/functions-library/utilities/pdf-templates#filltemplate) function within your backend logic. This function is the engine: it takes a data object (like a JSON object from a database), merges the values into your visual placeholders, and outputs the finished PDF document. For detailed input/output specifications, refer to the [PDF Templates class documentation](https://docs.heisenware.com/app-builder/build-backend/functions-library/utilities/pdf-templates).

To see these concepts in action, follow our step-by-step guide on [automating PDF reports](https://docs.heisenware.com/tutorials/app-templates/automating-pdf-reports).

## Deleting a template

If you no longer need a PDF template, you can permanently remove it and its associated function:

1. Navigate to the [Functions Library](https://docs.heisenware.com/app-builder/build-backend/functions-library).
2. Open the PDF Templates Class.
3. Right-click the specific template instance.
4. Select Remove.

{% hint style="danger" %}
This action is irreversible. Deleting an instance removes it completey. Any logic in your Flow Builder referencing this template will break.
{% endhint %}

<figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2F2RV0g3Pegtw8BweSuqyY%2Fdeleting_template_looped.gif?alt=media&#x26;token=62717c62-709c-4e74-b23e-c1e5b7ea5724" alt=""><figcaption></figcaption></figure>
