# PDF page layout: fonts, margins and cover pages

Configure portrait/landscape, Arabic RTL and mixed text, fonts, margins, backgrounds and watermarks in PDF templates.

When editing a template, some changes belong across the whole document, such as a new font or shared margins. Other parts may need their own treatment, like a cover with a colored background followed by white content pages.

Tembuilder lets you do both: set shared defaults in **Global**, then give individual pages their own margins and backgrounds in **Structure**. This guide shows you where to choose paper size and adjust typography, margins, and backgrounds.

## 1. Choose the paper size

Use the paper-size control in the preview area, shown as **A4** below. Paper size applies to the **whole template**; individual pages do not have a separate paper-size setting in Config.

Tembuilder supports 9 paper sizes:

| Paper size | Dimensions (width × height, mm) |
| --- | --- |
| A0 | 841 × 1189 |
| A1 | 594 × 841 |
| A2 | 420 × 594 |
| A3 | 297 × 420 |
| A4 | 210 × 297 |
| A5 | 148 × 210 |
| A6 | 105 × 148 |
| US Letter | 215.9 × 279.4 |
| Legal | 215.9 × 355.6 |

<figure class="doc-sim layout-illustration" aria-label="Preview → choose the paper size">
<div class="sim-stage"><div class="sim-panel"><div class="ls-preview-bar"><div class="sim-tabs"><span>Layout</span><span class="sim-active">PDF</span></div><span class="sim-control sim-focus">A4 <svg class="sim-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4" /></svg></span></div><div class="ls-paper-sizes"><div><div class="ls-sheet "><b>Tembuilder</b><strong>INVOICE</strong><div class="ls-lines"><i></i><i></i><i></i></div><div class="ls-lines"><i></i><i></i></div><small>01</small></div><small>A4 · 210 × 297 mm</small></div><div><div class="ls-sheet ls-letter"><b>Tembuilder</b><strong>INVOICE</strong><div class="ls-lines"><i></i><i></i><i></i></div><div class="ls-lines"><i></i><i></i></div><small>01</small></div><small>US Letter</small></div></div></div></div>
<figcaption>Preview → choose the paper size</figcaption>
</figure>

## 2. Set shared typography in Global

Open **Hierarchy → Global → Config → Typography**.

| Setting | Value and units |
| --- | --- |
| Font size | Size in **pt**, such as `12`. |
| Line height | A multiplier of the font size, such as `1.4`; do not enter `px` or `pt`. |
| Letter spacing | Character spacing in **em**, such as `0.02`. |
| Text align | Left, Center, Right, or Justify. |
| Text color | The shared text color. |

> [!WARNING] Warning
>
> These are default values. If a section sets its own `font-size`, `color`, or `line-height` in CSS, changing that setting in Global does not override the section’s CSS. If part of the content does not respond to a Global change, check that section’s **CSS** tab.

<figure class="doc-sim layout-illustration" aria-label="Global → Config → Typography">
<div class="sim-stage"><div class="ls-path">Structure <span>→</span> Global <span>→</span> Config</div><div class="ls-editor sim-panel"><div class="ls-structure"><div class="sim-panel-title">STRUCTURE</div><div class="sim-tree-row sim-selected">⌄ Global</div><div class="sim-tree-row sim-muted">⌄ Invoice</div><div class="sim-tree-child sim-muted">Billing Parties</div></div><div class="ls-config"><div class="sim-tabs"><span>Props</span><span class="sim-active">Config</span></div><div class="ls-card"><div class="ls-card-title">Typography</div><div class="ls-setting"><span>Font size</span><span class="sim-input sim-focus">12 <small>pt</small></span></div><div class="ls-setting"><span>Line height</span><span class="sim-input">1.4</span></div><div class="ls-setting"><span>Text align</span><span class="sim-input">Left <svg class="sim-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4" /></svg></span></div><div class="ls-setting"><span>Text color</span><span class="ls-color" aria-label="#111111"></span></div></div></div></div></div>
<figcaption>Global → Config → Typography</figcaption>
</figure>

## 3. Add and order fonts

Open **Global → Config → Fonts → Add font**, search for a Google Font, and add it to the list.

> [!NOTE] Information
>
> **The list order sets font priority.** Drag a font to the top or use the up/down controls to make it the first choice. Later fonts are fallbacks when an earlier one is unavailable or lacks a character.

A section with its own CSS `font-family` uses that font declaration instead of Global’s default order.

<figure class="doc-sim layout-illustration" aria-label="Global → Config → Fonts → Add font">
<div class="sim-stage"><div class="ls-path">Structure <span>→</span> Global <span>→</span> Config</div><div class="sim-panel"><div class="ls-fonts-head"><strong>Fonts</strong><span class="sim-control sim-focus">＋ Add font</span></div><div class="ls-font-row"><span class="ls-font-index">1</span><div><strong>Space Grotesk</strong><small>Google Fonts</small></div><span class="ls-font-sample">Aa</span></div><div class="ls-font-example">Type sample · Aa Bb Cc · 0123456789</div></div></div>
<figcaption>Global → Config → Fonts → Add font</figcaption>
</figure>

## 4. Set content margins

Open **Global → Config → Content margin**, enable margins, and enter **Top**, **Right**, **Bottom**, and **Left** in **mm**.

For example, A4 is `210 mm` wide. With left and right margins of `14 mm` each, the content area is `182 mm` wide. That is the width available for tables and sections.

Use page margins for the inset from the paper’s edges. Use `padding` and `margin` in a section’s CSS for spacing within or between content blocks.

**Mirror margin** swaps the left and right margins on even sheets for double-sided, bound documents. With Left `24` and Right `12`, odd sheets have a `24 mm` left margin and even sheets have a `24 mm` right margin.

<figure class="doc-sim layout-illustration" aria-label="Margins use mm · Mirror margin swaps left/right on even sheets">
<div class="sim-stage"><div class="ls-path">Global <span>→</span> Config <span>→</span> Content margin</div><div class="ls-margin-scene"><div class="sim-panel ls-margin-panel"><div class="sim-panel-title">Content margin <small>mm</small></div><div class="ls-margin-diagram"><div class="ls-m-top"><small>Top</small><span class="sim-input">14</span></div><div class="ls-m-left"><small>Left</small><span class="sim-input sim-focus">24</span></div><div class="ls-m-page" aria-hidden="true">▤</div><div class="ls-m-right"><small>Right</small><span class="sim-input">12</span></div><div class="ls-m-bottom"><small>Bottom</small><span class="sim-input">20</span></div></div><div class="ls-mirror-row"><span>Mirror margin</span><span class="ls-toggle" aria-label="On"></span></div></div><div class="ls-mirror-pages"><div><span>1</span><div class="ls-margin-paper"><div class="ls-margin-area"><i></i><i></i><i></i></div></div></div><div><span>2</span><div class="ls-margin-paper ls-margin-even"><div class="ls-margin-area"><i></i><i></i><i></i></div></div></div></div></div></div>
<figcaption>Margins use mm · Mirror margin swaps left/right on even sheets</figcaption>
</figure>

## 5. Override a page’s margins and background

Select a page in **Structure → Config** to override Global:

- **Custom margins → Content**: enable a separate content margin for the page.
- **Background → Page background**: enable a separate background color or image.

These settings are independent. A cover can have its own background while keeping shared margins, or a page containing a wide table can have its own margins.

> [!NOTE] Information
>
> Disable an override to use the **current Global value** again. While an override is enabled, changes to that Global setting do not apply to the page.

Headers and footers have their own margin and background settings when enabled. See [Headers and footers](/docs/editor/header-footer/) or [Using images](/docs/assets/images/) for the relevant details.

<figure class="doc-sim layout-illustration" aria-label="Select a page → Config → enable custom margins or background">
<div class="sim-stage"><div class="ls-path">Structure <span>→</span> Invoice <span>→</span> Config</div><div class="ls-page-scene"><div class="sim-panel ls-page-config"><div class="sim-tabs"><span class="sim-active">Config</span></div><div class="ls-card"><div class="ls-card-title">Custom margins</div><div class="ls-setting"><span>Content</span><span class="ls-toggle"></span></div><div class="ls-setting"><span>Left</span><span class="sim-input">24 <small>mm</small></span></div></div><div class="ls-card"><div class="ls-setting"><strong>Page background</strong><span class="ls-toggle sim-focus"></span></div><div class="ls-setting"><span>Color</span><span class="ls-color ls-color-page"></span></div></div></div><div class="ls-page-comparison"><div><small>Page 1 · Custom</small><div class="ls-sheet ls-custom-paper"><b>Tembuilder</b><strong>INVOICE</strong><div class="ls-lines"><i></i><i></i><i></i></div><div class="ls-lines"><i></i><i></i></div><small>01</small></div></div><div><small>Page 2 · Global</small><div class="ls-sheet "><b>Tembuilder</b><strong>INVOICE</strong><div class="ls-lines"><i></i><i></i><i></i></div><div class="ls-lines"><i></i><i></i></div><small>01</small></div></div></div></div></div>
<figcaption>Select a page → Config → enable custom margins or background</figcaption>
</figure>

## 6. Structure pages and PDF sheets

A **page in Structure** groups sections; it is not limited to one sheet of paper. Longer content can produce several PDF sheets from that group, and the page’s configuration continues to apply to those sheets.

To give a cover different margins or a background, make it a separate page in Structure. To control where content moves onto the next sheet, use the [page-break settings](/docs/editor/pagination/).

<figure class="doc-sim layout-illustration" aria-label="One Structure page can produce several PDF sheets">
<div class="sim-stage"><div class="sim-panel"><div class="ls-review-bar"><span class="sim-control">Layout</span><span class="sim-control sim-focus">PDF</span><small>A4 · 3 pages</small></div><div class="ls-review-pages"><div><small>Page 1</small><div class="ls-sheet "><b>Tembuilder</b><strong>INVOICE</strong><div class="ls-lines"><i></i><i></i><i></i></div><div class="ls-lines"><i></i><i></i></div><small>01</small></div></div><div><small>Page 2</small><div class="ls-sheet "><b>Tembuilder</b><strong>CONTENT</strong><div class="ls-lines"><i></i><i></i><i></i></div><div class="ls-lines"><i></i><i></i></div><small>01</small></div></div><div><small>Page 3</small><div class="ls-sheet "><b>Tembuilder</b><strong>CONTENT</strong><div class="ls-lines"><i></i><i></i><i></i></div><div class="ls-lines"><i></i><i></i></div><small>01</small></div></div></div><div class="ls-review-footer">1 / 3 <span>‹ &nbsp; ›</span></div></div></div>
<figcaption>One Structure page can produce several PDF sheets</figcaption>
</figure>

## 7. Choose the document orientation

Use the orientation control beside paper size in the preview area. **Portrait** suits vertical reading; **Landscape** provides more width for tables or diagrams. Orientation and paper size apply to the whole template. There is no page or variant orientation override. For A4, portrait is 210 × 297 mm and landscape is 297 × 210 mm. Check wrapping and pagination after changing direction.

<figure class="doc-sim layout-illustration" data-layout-example="orientation" aria-label="Portrait: 210 × 297 mm · Landscape: 297 × 210 mm · Content reflows after changing orientation.">
<div class="sim-stage"><div class="ls-path">Preview <span>→</span> A4 <span>→</span> Orientation</div><div class="lx-orientations"><div><div class="lx-paper-frame"><div class="ls-sheet"><b>Tembuilder</b><strong>Report</strong><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div></div></div><b>Portrait</b><small>210 × 297 mm</small></div><div><div class="lx-paper-frame"><div class="ls-sheet lx-landscape"><b>Tembuilder</b><strong>Report</strong><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div></div></div><b>Landscape</b><small>297 × 210 mm</small></div></div><div class="lx-scope">Whole document</div></div>
<figcaption>Portrait: 210 × 297 mm · Landscape: 297 × 210 mm · Content reflows after changing orientation.</figcaption>
</figure>

## 8. Set a watermark and page exceptions

Open **Global → Config → Watermark** for a shared text or image mark. Leave it off when no shared mark is needed. A watermark appears above the page background and below content on each physical PDF sheet; text is literal, so HTML and Handlebars expressions are not evaluated.

In a page’s **Config → Watermark**, choose:

| Mode | Use when | Effect |
| --- | --- | --- |
| Inherit (`inherit`) | The page should follow Global. | Follows the current Global mark, including later changes; no mark if Global is off. |
| Off (`off`) | A cover or other page must stay unmarked. | Suppresses the mark on this logical page, even if Global is on. |
| Custom (`custom`) | This page needs a different mark. | Replaces Global with a complete page-specific text/image configuration; works even if Global is off. |

Return to Inherit to follow Global again. These choices affect every PDF sheet produced by the logical page. A variant may override the page’s watermark mode/settings. Changing Global does not replace an Off or Custom choice.

Position X/Y uses percentages of physical page width/height; scale uses percent, rotation uses degrees, and opacity ranges from 0 to 1. Keep the mark subtle enough that text and tables remain readable. For MCP, use `global.config.watermark: null` for no shared mark and `pages[id].config.watermark: {"mode":"inherit"}`, `{"mode":"off"}`, or `{"mode":"custom","settings":…}` for the page choice. Set `orientation` at the schema root.

To configure the mark:

1. Select **Global → Config → Watermark**. In a non-base variant, choose **Customize** first to reveal this group’s controls.
2. Enable Watermark and choose **Text** or **Image**. For Text, enter the literal label and choose its font, size and color. For Image, select the image from Assets.
3. Drag the placement preview or use its position presets; refine X/Y, scale, rotation and opacity with the fields. Keep content legible.
4. Select the page’s **Config → Watermark** for an exception. In a variant, first customize that page’s watermark group; then choose whether to follow Global, switch the mark off, or supply its own settings.

<figure class="doc-sim layout-illustration" data-layout-example="watermark" aria-label="Global: DRAFT · Inherit keeps it, Off removes it, Custom replaces it on every sheet of that page.">
<div class="sim-stage"><div class="ls-path">Global <span>→</span> Watermark <span>→</span> DRAFT</div><div class="lx-watermarks"><div><div class="ls-sheet"><span class="lx-watermark" aria-hidden="true">DRAFT</span><div class="lx-paper-content"><b>Tembuilder</b><strong>Report</strong><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div></div></div><b>Inherit Global</b><small>inherit</small></div><div><div class="ls-sheet"><span class="lx-watermark" aria-hidden="true"></span><div class="lx-paper-content"><b>Tembuilder</b><strong>Cover</strong><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div></div></div><b>Off</b><small>off</small></div><div><div class="ls-sheet"><span class="lx-watermark" aria-hidden="true">COPY</span><div class="lx-paper-content"><b>Tembuilder</b><strong>Appendix</strong><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div><div class="ls-lines" aria-hidden="true"><i></i><i></i><i></i></div></div></div><b>Custom</b><small>custom</small></div></div></div>
<figcaption>Global: DRAFT · Inherit keeps it, Off removes it, Custom replaces it on every sheet of that page.</figcaption>
</figure>

## 9. Content direction: LTR, RTL and mixed text

Open **Hierarchy → Global → Config → Layout → Content direction**. Choose **Left to right (LTR)** or **Right to left (RTL)**. This is a horizontal content setting, independent of portrait/landscape. RTL is suitable for Arabic, Hebrew, Persian and Urdu templates; it does not translate content or choose a font.

Sections, headers and footers inherit the direction. Use **Typography → Text align → Start** to align at the beginning of the reading direction, or **End** for the opposite edge. Explicit Left, Right, Center and Justify retain their meaning. Section CSS can override alignment. The existing ordered font list is unchanged; add a font with the required script coverage.

For an Arabic invoice, start with Global RTL, Start alignment and a font that covers Arabic. Keep invoice IDs, currency amounts and URLs in LTR `bdi` spans; use `bdi dir="auto"` for names whose direction varies. Give an English-only Section LTR in its Layout config, or place a local `dir="ltr"` block inside the Arabic Section. The example below shows both Arabic text and isolated English data without reversing the source strings.

<figure class="doc-sim layout-illustration" data-layout-example="rtl" aria-label="Arabic RTL: the reading order follows the page. Invoice codes and the English block keep their own LTR direction.">
<div class="sim-stage"><div class="ls-path">Global <span>→</span> Page <span>→</span> Section</div><div class="lx-rtl-scene"><div class="lx-direction-config sim-panel"><div class="sim-panel-title">LAYOUT</div><div><small>Content direction</small><span class="sim-control lx-selected">RTL ←</span></div><div><small>Text align</small><b>Start</b></div><div><small>Font</small><b>Noto Sans Arabic</b></div><div><small>Local HTML override</small><code>dir="ltr"</code></div></div><div class="lx-invoice" dir="rtl" lang="ar"><div class="lx-invoice-header"><span class="lx-logo" dir="ltr">TB</span><strong>فاتورة</strong></div><p>رقم الفاتورة: <bdi dir="ltr">INV-2026-014</bdi></p><p>العميل: <bdi dir="auto">Alice Martin</bdi></p><table><thead><tr><th>الوصف</th><th>المبلغ</th></tr></thead><tbody><tr><td>خدمة التصميم</td><td><bdi dir="ltr">USD 120.00</bdi></td></tr></tbody></table><div class="lx-english" dir="ltr" lang="en"><b>Payment instructions</b><span>Use reference <bdi dir="ltr">INV-2026-014</bdi>.</span></div></div></div></div>
<figcaption>Arabic RTL: the reading order follows the page. Invoice codes and the English block keep their own LTR direction.</figcaption>
</figure>

**Page → Config → Layout** and **Section → Config → Layout** offer **Inherit / LTR / RTL**. Inherit follows the current parent, including future changes: **Global → Page → Section**. A page override also controls its running header/footer; a section override affects only that section. Choose Inherit again to remove the local choice. A nested HTML `dir` can still set its own direction; `lang` is optional and is not required for direction.

Content direction is part of **template format v1**. Set the required `global.config.direction` field to `ltr` or `rtl`. The following is a **configuration excerpt**, not a complete schema for `template_apply`:

```json
{
  "schemaVersion": 1,
  "$schema": "https://api.tembuilder.com/schemas/template-v1.json",
  "global": {
    "config": {
      "direction": "rtl",
      "typography": { "textAlign": "start" }
    }
  },
  "pages": {
    "p1": { "config": { "direction": "ltr" } }
  },
  "sections": {
    "notes": { "config": { "direction": "inherit" } }
  }
}
```

Keep source text in logical reading order. Use `dir="ltr"` on an English block, `<bdi dir="ltr">` for known LTR identifiers, and `<bdi dir="auto">` for names whose direction varies. Ordinary `{{ ... }}` interpolation keeps values escaped. Do not reverse strings or use a document-wide bidi override. Declare the appropriate typed props and parameters before using this example; `props.logo` is an asset prop.

```html
<div lang="ar">
  <div class="identity">
    <img src="{{ props.logo }}" alt="Logo" width="48" height="48">
    <h1>فاتورة</h1>
  </div>
  <p>رقم الفاتورة: <bdi dir="ltr">{{ params.invoice_id }}</bdi></p>
  <p>العميل: <bdi dir="auto">{{ params.customer_name }}</bdi></p>
  <p>الإجمالي: <bdi dir="ltr">USD 123.45</bdi></p>
  <div dir="ltr" lang="en">Payment instructions in English.</div>
</div>
```

```css
.identity {
  display: flex;
  align-items: center;
  gap: 12px;
}
.identity h1 {
  margin: 0;
  padding-inline-start: 8px;
  text-align: start;
}
```

Flex rows and tables follow their inherited direction unless CSS overrides it. Prefer `margin-inline-start`, `padding-inline-end` and `text-align: start` for adaptable layouts. Physical `left`, `right`, absolute coordinates and explicit `row-reverse` rules are not rewritten. Images, logos and QR codes are never automatically reflected.

> [!NOTE] Information
>
> Paper geometry, physical margins, mirror parity, page order, background/watermark coordinates and binding are unchanged. RTL does not add right-hand binding or vertical writing. Language-specific line breaking, glyph coverage and shaping still depend on the font and renderer; this setting is not a guarantee of every writing system.

Review both Layout and PDF preview using real mixed-language data and enough content to create continuation pages. Check punctuation around names, URLs, codes and amounts; table column order; image placement; headers/footers; margins; missing glyphs; and copy/search in the downloaded PDF. If alignment stays on the left, inspect explicit Global text alignment and section CSS. If a value moves surrounding punctuation, isolate that value with `bdi`.

Every variant has the full **Config** tab for **Global, Header, Footer, Page and Section**, using the same controls as Standard. Global controls direction, typography, font order, margins/mirror, background and watermark. Header/Footer control visibility, margins/mirror and background. Page controls direction, independent Header/Footer Off / Inherit / Customize modes, local margins, backgrounds and watermark. Section controls direction and page breaks.

For each group, choose **Follow Base / Customize**. Follow Base removes that group’s override; future Base edits apply again. Customize starts with the values currently shown and saves that group only for the selected variant. Follow Base hides that group’s editing controls; choose Customize to show them. A customized typography group or font list is independent as a whole; font order remains font priority. Switching a background or watermark off is a saved choice, distinct from following Base. Page watermark still supports inherit Global, off and custom. At page level, a disabled margin/background override follows Base’s page setting; use zero custom margins or an empty custom background when intentionally clearing one.

Direction uses **Base / LTR / RTL**. Base follows the setting at the same scope; if Base inherits its parent, it follows this variant’s effective Global or Page. Explicit HTML `dir` still controls its own subtree. Global and section HTML/CSS, paper size, orientation and structural additions/removals are shared in Standard. A customized page Header/Footer has its own HTML, CSS, props and Config; editing an inherited copy in another variant creates an independent copy. Review Layout and PDF after switching variants, especially when fonts or page breaks change pagination.
