Skip to content

Recipe: page options

This recipe builds a Dunder Mifflin paper catalog in one PDF: a cover, then one page per product with its name and price. The page numbers count the pages that are actually printed.

You’ll learn the page’s Repeat, page numbers and the Page number and Page count variables, and how to spread a long list over several pages.

The catalog cover

One product page, repeated for every item of the products list

Click an empty area of the canvas so that nothing is selected. The context bar becomes the page bar.

Control What it does
Page N The page you’re on
Repeat Export the page once per item of a list variable
Show Export the page only when a boolean is true (or false)
Page numbers Number every page of the template

The same Repeat and Show are in the ⋯ menu of each thumbnail in the pages panel, and a thumbnail shows a badge when its page is bound.

On My Templates, click New Template. Name it Paper catalog, choose A4 portrait and click Create.

Name Type Settings
products List Max items 100. Item fields: name (String, 40, required) and price (String, 12, required)

Give products a couple of default items, such as A4 copy paper and envelopes, so the preview has something to show.

Page 1 is a plain page with fixed text: DUNDER MIFFLIN PAPER COMPANY, then Paper catalog in large type and Scranton branch under it. Nothing to bind.

  1. Click + Add in the pages panel to add page 2. Draw a text box near the top for the product’s name, in bold, 64, and a second one under it for the price, in 40.

  2. With nothing selected, click Repeat in the page bar and pick products. The button reads Repeat: products, and the thumbnail shows a ⟳ badge.

  3. Bind the texts to the current product. Put the caret in the first text box, click Variable (⚡) and pick products.name, then do the same with products.price in the second. The item’s fields are offered once the page repeats.

The editor shows the page once. In the PDF, the page is replaced by one copy per product, in the list’s order. An empty list leaves the page out.

  1. In the page bar, click Page numbers (the # button) and switch on Number the pages. A text box appears at the bottom right of every page.

  2. Check Skip the first page. The cover gets no number but still counts, so the first product page shows 2.

  3. Select the number on any page to restyle, move or reword it, and every page follows. For Page 2 of 5, type Page , insert Variable → Page → Page number, type of, and insert Page count.

Page numbers are counted in the PDF, after repeated pages are copied. With 4 products, the product pages read Page 2 of 5 to Page 5 of 5. A repeated page shows the number on all its copies or on none.

Page number and Page count work in any text box, outside the numbering too: Catalog (5 pages) on the cover, or a reference such as p. 3 in a header.

Nothing flows from one page to the next, so a table longer than its page loses its last rows, with a warning. To print a list of any length, cut it into pages in your code and let a repeated page draw them.

  1. Declare a pages variable of type List, with the item fields lines (List, with the fields of a line) and isLast (Boolean).

  2. Design one page of the table, as in Lists and tables, and set the page’s Repeat to pages.

  3. Set the line row’s Repeat to pages.lines, under Item lists. Each page copy draws its own lines, read from pages.lines.label, pages.lines.amount…

  4. Set the total row’s Show to pages.isLast, so the total prints on the last page only.

Then send the lines in chunks of as many as a page holds:

const LINES_PER_PAGE = 15;
const pages = [];
for (let i = 0; i < lines.length; i += LINES_PER_PAGE) {
pages.push({ lines: lines.slice(i, i + LINES_PER_PAGE), isLast: false });
}
pages.at(-1).isLast = true;
const body = { clientName: 'Bob Vance', total: '$12,480.00', pages };

With a cover before it and the numbering on, a 40-line invoice for Vance Refrigeration prints as Page 2 of 4 to Page 4 of 4, with its total on the last page.

  • Dundie Awards for the whole office in one PDF: a single page repeated on nominees, each copy reading nominees.name and nominees.category.
  • Employee badges ready to print: the badge design on a page repeated on employees, with one request for the whole Scranton branch.
  • A table on each product page: a variants list field, drawn by a group repeated on products.variants (see Lists and tables).