# Get to know Tembuilder concepts

How templates, pages, sections, data and configuration work together to create PDFs.

These concepts form one PDF creation flow: build a template, configure it, supply data and render the document. You can follow our standard workflow below:

Set up structure → Define styling → Design data → Configure layout → Configure pagination → Export PDF

## Start with a template, pages and sections

To create a PDF in Tembuilder, start by organizing your content in a template. The document structure has the following parts:

- **Template:** Defines the content and presentation of the whole document and contains one or more pages.
- **Page:** Organizes content within the template. Each page contains sections.
- **Section:** A content block with its own HTML/CSS, so you can edit each part independently.
- **Layout:** Defines page order, which sections belong to each page, and the order of sections within a page.

Once the structure is ready, use Global to give the document a consistent style.

## Set the shared style with Global

Once the structure is ready, use Global to set shared presentation for the whole template. Pages inherit these settings to keep the document consistent:

- **Fonts:** Declare the fonts used in the document and their order of preference.
- **Typography:** Set the default font size, line height, letter spacing, text alignment and text color.
- **Content margins:** Set top, bottom, left and right margins, with mirrored margins for odd and even sheets if needed.
- **Page background:** Set a background color or image, including image size, position and repeat behavior.
- **Headers and footers:** Set shared content at the top and bottom of pages, with margins and backgrounds for each area.

Fonts, typography and margins affect wrapping and pagination. Break behavior for each section is configured separately in the pagination settings.

A page can enable its own margin or background when needed. A section can also have its own props; these are available only within that section.

With structure and style ready, the next step is to separate values stored in the template from data supplied for each PDF.

## Fill the content with props and parameters

Depending on how you design your data, you can choose one of two approaches:

- **Props (properties):** Store values in the template, suitable for heading labels or content reused across renders.
- **Params (parameters):** Supply data for each render, suitable for content that changes from one document to another. Values can be text, numbers, an object or a list.

The engine fills each section’s HTML/CSS with these values. One template can be reused with different inputs; variants can change props or layout for another design. Different data can also produce longer content, which must then be laid out within the page area.

## Configuration sets the available space

Choose the document’s paper size and set margins to define its content area. The dashed outline in the illustration marks the space available after margins are applied.

- **Paper size:** Choose from the supported sizes: A0, A1, A2, A3, A4, A5, A6, US Letter and Legal.
- **Content margins:** Set individual values for the top, bottom, left and right edges. Use shared Global margins or configure separate margins for each page.
- **Presentation:** Fonts, type size, line height and section CSS determine how content fits within the configured area.

Paper size and margins together determine the space available for content. When content no longer fits on a sheet, pagination settings determine how it splits or moves to the next sheet.

## Paginate the longer document

A template page groups content that can span several PDF sheets when rendered. Headers and footers repeat on those sheets, while sections continue in layout order.

In a section’s Config, combine the keep-together setting with a page-break option before or after the section:

- **Keep together:** When enabled, prefer keeping the entire section on one sheet. If the remaining space is insufficient but the section fits on a full sheet, move it to the next sheet. When disabled, content may split across sheets.
- **None:** Do not force a break before or after the section; content continues in the available space.
- **Before:** Start the section on a new sheet when content precedes it within the same template page.
- **After:** Move the next section within the same template page to a new sheet.
- **Both:** Start the section on a new sheet and move the following section to another sheet.

For example, enable Keep together for a short signature block to avoid splitting it, while allowing a long table to span sheets. These settings do not shrink content; an oversized section can still exceed the available space on a sheet.

## Bring it together in one render

Once structure, presentation and data are ready, Tembuilder combines them to create a PDF in the following steps:

- **Choose the template:** Use the template and variant you want to render.
- **Resolve the design:** Determine page and section order, props and the applicable configuration.
- **Fill in the data:** Insert the parameters supplied for this render into the template content.
- **Build the document:** Assemble the parts’ HTML/CSS into a complete document.
- **Paginate and export:** Split content into sheets using the paper size, margins and break rules, then generate the PDF file.

While designing, live Preview helps you inspect the content and layout you are editing. To check the actual sheet count, headers, footers and page breaks, view the result in the PDF tab.
