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 |
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. |
3. Add and order fonts
Open Global → Config → Fonts → Add font, search for a Google Font, and add it to the list.
A section with its own CSS font-family uses that font declaration instead of Global’s default order.
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.
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.
Headers and footers have their own margin and background settings when enabled. See Headers and footers or Using images for the relevant details.
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.
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.
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:
- Select Global → Config → Watermark. In a non-base variant, choose Customize first to reveal this group’s controls.
- 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.
- Drag the placement preview or use its position presets; refine X/Y, scale, rotation and opacity with the fields. Keep content legible.
- 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.
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.
dir="ltr"رقم الفاتورة: INV-2026-014
العميل: Alice Martin
| الوصف | المبلغ |
|---|---|
| خدمة التصميم | USD 120.00 |
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:
{
"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.
<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>
.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.
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.