Pagination
Control where pages break with CSS.
Content flows across pages at the width available inside the margins. Use CSS break properties to start chapters, keep related content together, and control how paragraphs split. Percentage heights do not resolve in this mode because the content has no fixed height.
Break properties
import { } from "takumi-pdf";
const = await (
<>
< ={{ : "page" }}>Chapter two</>
< ={{ : "avoid" }}>Keep this together.</>
</>,
);| Property | Effect |
|---|---|
break-before: page | Starts the element on a new page. |
break-after: page | Starts the following content on a new page. |
break-inside: avoid | Keeps the element on one page when it fits. |
box-decoration-break: clone | Repeats borders and backgrounds on every page fragment. |
break-inside: avoid applies only when the box fits on a page. An oversized box can still split. Text lines, images, and transformed subtrees are kept together where possible.
Widows and orphans
A cut through a paragraph keeps at least orphans lines at the bottom of the page and widows lines at the top of the next. Both default to 2, like Chromium. Set them to 1 to allow lone lines:
import { } from "takumi-pdf";
const = await (
< ={{ : 3, : 3 }}>
A long report body wraps into many lines across the page boundary.
</>,
);Both properties inherit. If a paragraph is too short to satisfy both values, orphans takes priority. A paragraph moves to the next page when the current page cannot hold the required lines. A requirement larger than a full page is relaxed.
Split decorations
A box that crosses a page break slices its border and background by default. Set box-decoration-break: clone to give each fragment complete decorations:
import { } from "takumi-pdf";
const = await (
<
={{
: "1px solid #d1d5db",
: 8,
: "clone",
}}
>
Long content that continues on the next page.
</>,
);Repeated table headers
Use <thead> for column headings that repeat on continuation pages. The header stays together, including its spacing before the first body row.
import { } from "takumi-pdf";
const = await (
<>
<>
<>
<>Name</>
<>Qty</>
</>
</>
<>{}</>
</>,
);A header taller than a quarter of the page does not repeat, matching Chromium. A header cell whose rowspan reaches into the body suppresses repetition for that table. <tfoot> renders once, after the body.
Page ranges
pageRanges keeps only the listed pages, like a print dialog. Each entry is a 1-based page number or an inclusive span:
import { } from "takumi-pdf";
const = await (<>{}</>, {
: [1, { : 4, : 8 }, { : 12 }],
});An unset from starts at the first page. An unset to runs to the last. Ranges that keep no page reject the render.
Layout and page counters still run over the whole document. A kept page shows the numbers it would in full output, so page 4 of 12 still reads "Page 4 of 12". Links and outline entries pointing at a dropped page are dropped with it.
Watermarks
position: fixed paints a box on every page.
The box lays out against the page area.
It stays outside the content column.
import { } from "takumi-pdf";
const = await (
<>
<
={{
: "fixed",
: 0,
: "flex",
: "center",
: "center",
}}
>
< ={{ : 96, : "rgba(0,0,0,0.08)" }}>DRAFT</>
</>
<>Long content that continues on the next page.</>
</>,
);Place the fixed box outside transformed or filtered ancestors. Those ancestors contain the box, so it paginates with them instead of repeating independently.
Use a negative z-index to place the watermark behind content. Set the page color through backgroundColor if the root background would otherwise cover the watermark.
Last updated on