Overflow & pagination

auto-shrink vs grow-and-push, roles, page breaks.

Real data is never the length you designed for. An invoice has three line items today and ninety next month; a certificate gets a name twice as long as the placeholder. Every element therefore carries an overflow policy that says what to do when the content no longer fits.

The one rule people get backwards
The right policy depends on whether the canvas is fixed or the document flows — and the two answers are opposites. A certificate, gift card or social image is a fixed rectangle: it can never grow, so text must shrink. An invoice or report flows onto more paper: text must stay legible and push the content below it down. Same property, opposite correct value.

The three policies

  • auto-shrink — keep the box, reduce the font size until the text fits. Correct for fixed-size designs: certificates, gift cards, ID cards, OG images.
  • grow-and-push — keep the font size, let the box grow and move everything below it down, spilling onto a new page when needed. Correct for flowing documents: invoices, receipts, reports, resumes.
  • max-lines-ellipsis — hard-clip at maxLines and end with an ellipsis. For places where truncating is genuinely better than shrinking or growing, such as a product blurb in a card.

Setting a sensible floor

auto-shrink without a floor will happily render a name at 4pt to make it fit. Always pair it with minFontSize, and usually maxLines too. The floor is a design decision: below it, you would rather the text wrapped or the caller sent something shorter.

json
{
  "name": "Recipient Name",
  "overflowPolicy": "auto-shrink",
  "minFontSize": 26,
  "maxLines": 1
}

How a document decides to break

Pagination is driven by content, not by fixed page counts. As elements grow, PixlDocs measures the used height against the page's content bounds; when the next element no longer fits, it starts a new page. Elements marked as page furniture repeat on every page rather than flowing.

  • fixed_background — page background, painted on every page.
  • fixed_decoration — borders, seals, rules, watermarks. Chrome, repeated.
  • variable_text — copy that comes from data and participates in flow.
  • variable_image — an image whose source comes from data.
  • repeated_section — a row or entry that multiplies with an array.
Roles are not decoration
A template with no roles set still validates, but every protection is switched off — the renderer cannot tell a border from a headline, so nothing is safe to shrink, repeat or break. Setting roles is what takes a template from "renders once" to "renders reliably for any input".

Tables that grow with the data

A table becomes data-driven by marking one row as the template row and pointing it at an array. That row is then repeated once per entry, and the table paginates with the document — headers repeat on each new page, and totals stay with the last one.

json
{
  "tableData": {
    "repeat": { "from": "lineItems", "templateRow": 1, "label": "Line item" }
  }
}

Cells inside the template row carry a field naming which key of each entry they render, so lineItems[n].description lands in the description column.

Checking it before your customers do

Guessing whether a template survives real data is the slow way. Stress-testing renders it against generated edge cases — very long values, missing optional fields, short values, alternate fonts — and reports which elements failed and why.

  • A template that is genuinely safe reports api_ready: true with no failing variants.
  • Fix the failures by setting a policy and a floor, not by shortening the placeholder text.
A quick sanity check
Send your longest realistic value and your shortest one through the same template. If the layout holds at both ends, it will hold in between.