> For the complete documentation index, see [llms.txt](https://docs.ninox.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ninox.com/getting-started/builder-getting-started/set-up-your-ninox-manually/create-print-layouts-and-generate-pdfs.md).

# Create print layouts and generate PDFs

Learn how to create print layouts, edit them, and generate PDFs from your records.

## Create your first print layout <a href="#create-your-first-print-layout" id="create-your-first-print-layout"></a>

Use a print layout to turn an invoice record into a printable PDF.

{% hint style="info" %}
Only users with the **Admin** role can save print layout changes.
{% endhint %}

{% stepper %}
{% step %}
**Open the print editor**

In the “Invoices” table, open an invoice record. Click the <i class="fa-print">:print:</i> printer icon in the top right. You can also open the three-dot menu and select **Print this record**.

The first time you do this in a table, Ninox opens an empty print layout.
{% endstep %}

{% step %}
**Add content to the layout**

Click **+ Insert** in the top bar and add the elements you need:

* **Text** for a static text or a value returned by a script
* **Image**, for a static image
* **Data** fields from your current table
  {% endstep %}

{% step %}
**Adjust the layout elements**

* Click an element to highlight its frame. Then drag it to a new position.
* Drag the square handles to resize it.
* Click **Edit script** **<>** in the top right to update the content of a field or element.
  {% endstep %}

{% step %}
**Save your changes**

Click **Save changes** when you are finished with the layout.
{% endstep %}

{% step %}
**Name the first layout**

Enter a **Layout name** and click **Save**.
{% endstep %}
{% endstepper %}

### Create another print layout <a href="#create-another-print-layout" id="create-another-print-layout"></a>

You can save multiple print layouts in the same table.

Click the arrow next to **Save changes**. Select **Save as** to save the current layout under a different name. Then adjust it as needed.

## Add a button to generate the invoice PDF <a href="#add-a-pdf-button-to-generate-and-attach-the-invoice-pdf" id="add-a-pdf-button-to-generate-and-attach-the-invoice-pdf"></a>

Once you have at least one print layout for your invoices, you can add a button on the “Invoices” table to:

* Generate a PDF using a defined print layout.
* Attach the generated PDF to the invoice record.
* Optionally, display the file in a field on the form view.

{% stepper %}
{% step %}

### Add a file field

[Add the field](/getting-started/builder-getting-started/set-up-your-ninox-manually/your-first-app.md#add-fields-to-your-tables) to the form view.\
This field is not required to create and attach the PDF. We recommend it if you want to see the file at a glance in the form view.
{% endstep %}

{% step %}

### Add the button and it's logic

Open the **Settings** panel on the right.\
Select **Form**, **Add**, and drag a **Button** from the **Controls** section on the form.

* In the **Button** settings, scroll to **General** and **On click**.
* Add the following script:

{% code overflow="wrap" %}

```
let myFileName := "Invoice-" + invoice_number + "-" + format(today(), "YYYY-MM-DD") + ".pdf";
do as server
	invoice_pdf := importFile(this, 
														printAndSaveRecord(this, "Invoice"), 
														myFileName)
end
```

{% endcode %}
{% endstep %}

{% step %}

### What the script does

`let myFileName := ...` builds a file name for the PDF:

* `"Invoice_"` is the fixed prefix.
* `+ invoice_number` adds the value from the “Invoice number” field to the prefix.
* `+ "-"` adds a hyphen as separator between the invoice number and the date of today.
* `format(..., "YYYY-MM-DD")` formats the date as `2026-08-15`.
* `+ ".pdf"` adds the file extension.

The `do as server...end` block runs the enclosed code on the server.\
`printAndSaveRecord()` must run there.

`invoice_pdf := importFile(...)` stores the file reference in the "Invoice PDF" field.\
This lets you display the PDF in the form.

`importFile(...)` attaches the file to the current record. The file appears in the <i class="fa-paperclip-vertical">:paperclip-vertical:</i> **Files** tab.

* `this` targets the currently open record.
* `printAndSaveRecord(this, "Invoice")` generates a PDF from the current record (`this`) using the print layout named `"Invoice"`.
* `myFileName` provides the generated file name.

{% hint style="warning" %}
Slashes `/` are not allowed in any filename.\
Format every date used in a filename. For example, format `today()` as `YYYY-MM-DD`, as shown above.\
An unformatted date can contain slashes and cause PDF generation to fail.
{% endhint %}
{% endstep %}
{% endstepper %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvgUdF91rY6UMBUb5r9Cl%2Fuploads%2FX95n0N95vQ2ZXHcT5Coh%2Fprint_and_save_pdf.mp4?alt=media&token=94ae2396-50ae-4c5f-ab9d-485f586fd2dc>" %}

## Edit layout elements

Existing print layouts stay editable at any time. When you open the print editor, you are already in edit mode.

* At the bottom of the page, use **Show grid** to show or hide the grid.
* Use the **Zoom** slider to zoom in or out.
* Use **Undo** and **Redo** to reverse or restore changes.
* Use **Cut**, **Copy**, and **Paste** to reuse recurring styles and content.
* Open the three-dot menu in the top bar to arrange and align elements:
  * **Send to front** and **Send to back**
  * **Align left**, **center**, or **right**
  * **Align top**, **middle**, or **bottom**
  * **Distribute horizontally**
* To remove an element, select its frame and click <i class="fa-trash-can">:trash-can:</i> **Remove**, or press <i class="fa-delete-left">:delete-left:</i> delete or <i class="fa-delete-right">:delete-right:</i> backspace on your keyboard.

Use the settings panel to adjust the layout. Available options depend on what you select.

Select the page to change page settings. Select a text, data, image, or linked table element to adjust its position, size, styling, and display options.

### Adjust page settings

Click an empty area or the page margin to edit the page layout. You can set:

* **Paper size**
* **Header and footer** height
* Page **Margin** width
* **Print attachments** to include record attachments in the PDF

### Adjust element settings for text, logic, or data fields

If you select a text box, logic, or data field, but not an image field, you can set:

* The page area, such as **Flow with content** or a repeating **Header** or **Footer**
* A fixed or automatic element **Height**
* The exact element **Position** with X and Y coordinates, plus **Width** and **Height**
* Inner **Padding** between the content and the element border
* **Colors** for the background and text
* **Border** color, width, and radius
* **Font** family and size
* Text formatting such as **Bold**, **Italic**, or **Underline**
* **Text** alignment
* Text **Line height**

### Adjust file and image field settings

For a file field and the static image, you can set:

* The page area, such as **Flow with content** or a repeating **Header** or **Footer**
* A fixed or automatic height
* The exact element **Position** with X and Y coordinates, plus **Width** and **Height**
* **Background color** for field areas not covered by the image
* **Border** color, width, and radius

### Adjust content and column settings for linked tables

This section applies when the print layout shows records from a linked table.

Use these settings to control which linked records and columns appear in the PDF. This is useful, for example, when a customer should see only relevant details.

{% hint style="info" %}
These changes apply only to the print layout. They do not change the underlying linked table.
{% endhint %}

Select the table shown in the print layout for a field of type <i class="fa-arrow-left">:arrow-left:</i> **Link many records** to control its content and presentation in the PDF. You can use all options listed above for **Text**, **Logic**, and **Data** fields, except **Text** alignment and text **Line height**.

You can also use these linked-table options:

* **Show header** to show or hide the column titles
* **Show footer** to show or hide aggregation results for columns where you set an **Aggregation**
* **Hide columns**, **Filter**, and **Sort**
* **Border style** to choose how the table grid looks
* **Cell padding** to define the distance between the value and the cell borders

You can also change table columns directly in the selected table frame:

* Use <i class="fa-eye-slash">:eye-slash:</i> x **hidden columns**, **Filter**, and **Sort** at the top right
* In the drop-down menu for each column:
  * **Rename column**
  * **Duplicate column**
  * **Insert column left** or **right**
  * **Sort** in ascending or descending order
  * **Aggregation**, depending on the data type, which you can display in the footer with **Show footer**
  * **Hide column**

## Generate a PDF <a href="#generate-a-pdf" id="generate-a-pdf"></a>

When your print layout is ready, click **Generate document** in the top right. By default, the PDF opens in your browser.

Click the arrow next to **Generate document** to choose what to generate:

* **Generate for selected record**
* **Generate for all records**\
  This option creates a single PDF containing all records of the open table view on separate pages.

{% hint style="info" %}
**Generate for all records** is available only when you open the record from a table view.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ninox.com/getting-started/builder-getting-started/set-up-your-ninox-manually/create-print-layouts-and-generate-pdfs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
