Pages and sections as PDF
A section of a Récit site (a category of its navigation) prints as one PDF: its pages in the order of the navigation, without the menu, the sidebars or the buttons, Mermaid diagrams drawn, links between its pages turned into links inside the file. The command prints the site's build as it is: no second build, no script of your own. The same command prints the decks the site publishes, one PDF each, downloadable from the deck's page (The published decks).
1. Say what prints (recit.config.ts)
The pdf key of the site's docs section lists the sections, each by the label of its category (or
the route of one of its pages):
recit.config.ts
The section must be there when the site is built: it is what makes each page hand its navigation
over to the PDF (?print=1) and show the download button. defineConfig of recit/config adds
@recit/, which does both.
2. Build, then print
Bash
Each PDF is written into the build (dist/ by default) and listed in
dist/. Deploy dist/ as usual: the PDF goes with it. Chromium comes from Playwright,
an optional peer of the CLI (pnpm add -); print in
CI, never on the host that serves the site.
3. The download button
On every page a PDF of exports.json holds, a button above the content offers it ("Download “…”
(PDF)"). It reads exports.json when the page opens. A site with docs.pdf, publish.pdf or
publish. writes an empty exports.json (files: []) at build time, sealed like
every other file on an encrypted site, and recit export -- (or
recit export --) fills it in: a preview before the export shows no button and logs
no 404, and never links to a PDF that is not there.
On a site encrypted with a password (access.,
Password protection) the button works the same once the
password is given. The PDF is encrypted in the build like every other file, so the button does not
let the browser save the file it is served: it fetches the PDF through the page, which decrypts it,
and saves the decrypted copy under its own name (docs.pdf, not RCT1… bytes). While it works the
button says so ("Preparing the download…"), and a download that fails says that too. The decrypted
copy exists only in the memory of the tab until it is saved: no cache, no server, nothing in clear
in the build.
Link a PDF from a page: <PdfDownload>
Any PDF of the build, the docs' or a deck's, can be linked from an MDX page with the same download, encrypted site or not:
pages/catalogue.mdx
A published deck's PDF is at <routePrefix>/ by default, next to its page
(/presentations/ → presentations/), so a catalogue of decks links each one by that
path (The published decks). On a multilingual site each language has its
own PDF next to its own page: presentations/ for the default language,
fr/ for French, and under i18n. the default
language too (en/): the path to give <PdfDownload>.
| Prop | Default | Description |
|---|---|---|
path | — | the file from the root of the site, without the base path (pdf/docs.pdf) |
title | — | names the file in the default label: Download “…” (PDF), Télécharger « … » (PDF) |
fileName | the last segment of path | the name the file is saved under |
appearance | link | button frames it like the button above the pages |
lang | metadata.lang | the language of the default label and of the messages |
| children | the default label | the text of the link |
On a site in clear it is a plain <a href download>. It does not check that the file exists: link
the PDF your CI prints. A PDF printed at commit and injected by the build
(prebuilt PDFs, on a site whose host has no Chromium)
is at the same path, so the same path works: the build reseals it with its own key and lists it in
the sealed files of its envelope (recit-), and the page decrypts it like the others.
Hide or move the button: docs. pdf. button
The button sits above the content by default. docs. moves it under the content or hides
it, for a site that offers its PDFs with <PdfDownload> only (a catalogue page, a summary):
recit.config.ts
The print does not depend on it: with button: the docs PDFs are still printed and listed in
exports.json, and a page can still offer them with <PdfDownload> (by path). Hide the button
through this key, never through a class of the component: its class names are internal and change
without notice.
4. The published decks
The decks a site publishes (publish.dir and publish.,
Stories in a site) print too, one PDF per deck, when the
site sets publish.pdf:
recit.config.ts
| Key | Default | What it does |
|---|---|---|
decks | every published deck | The slugs of the decks printed (a slug that no deck has is an error naming the others) |
notes | the deck's own (false) | A page of speaker notes after each slide that has notes |
colorMode | the deck's own | light or dark |
output | <routePrefix>/ | Where each PDF goes in the build, relative to it: {slug}, {locale}. On a multilingual site, see Multilingual sites |
Each deck prints the way recit export -- prints it, with the recit. found
next to it (its theme, its deck.pdf): publish.pdf sits over that config, and the deck's own
pdf: front matter over publish.pdf, so one deck can keep its notes while the others drop them.
Bash
--decks and --deck print even without publish.pdf; --section, --page and --scope print
the docs only. Each PDF is written into the build and listed in its exports.json with the deck's
route; on an encrypted site the PDFs and exports.json are encrypted with the build's key, like the
docs' PDF. With @recit/pptx installed (preview, see Exporting),
recit export -- (or --deck <slug>) writes each published deck's .pptx next to
its page and lists it in exports.json (--prebuilt puts it into recit-pdf/).
For any published story in publish. that sets exports ("images", "pdf", "mp4"),
recit export -- (with no --to) writes its PDF at <routePrefix>/, its
images under <routePrefix>/, and its film at <routePrefix>/ (with its
captions and transcript alongside it; "mp4" requires Chromium and ffmpeg, like recit render, and
fails on a format that has no film) inside the build, and lists every file in exports.json (with
the story's route on the PDF). Each entry's slug must stay inside the build and resolve to a
unique output path, or the command fails with an error. A nested slug (2026/launch) writes its
files into the matching subfolder under <routePrefix>/. On a multilingual site (i18n), each
language the story has a variant for (story.fr.md next to story.md) is exported too, under its
page's language prefix (<locale>/, and <defaultLocale>/ too under
i18n.), and listed in exports.json with its locale. On an encrypted
site (access.), --entries seals every exported file and exports.json with the
build's key (requiring the password variable, with nothing written in clear in dist/, like
--to pdf --). --entries refuses --prebuilt, --locale, --all-, --no-
and --output. A site that declares publish. alone still reads exports.json
and shows its exported media. On an unsealed site, each entry's PDF also gets its first-page PNG
preview in the build and in exports.json.
A story's own PDF (recit export --) — like an entry's PDF exported with --entries
— gets a PNG of its first page next to it, and its entry in exports.json names it in preview:
preview.path (relative to exports.json), preview. and preview. in pixels. The
docs' PDFs, the decks printed with --to pdf --, the variants (--variants) and any PDF of an
encrypted site have no preview.
On the deck's page, the toolbar then offers "Download the deck (PDF)" ("Télécharger le deck
(PDF)" in French), also in the "Options" menu the toolbar folds into under 480 px. It reads
exports.json when the page opens, on a site that sets publish.pdf or
publish.: a deck without a PDF shows nothing. On an encrypted site it downloads
the decrypted file, as the docs' button does. The key P downloads it too, and the deck's
shortcut help (?) lists "Download the PDF" in its Tools group ("Télécharger le PDF"), only when
the deck has a PDF.
A deck embedded in a page with <StoryEmbed> offers it only when asked, with pdf:
MDX
Multilingual sites
On a site with i18n, a deck is published in its default language and in each language it has a
variant for (deck.fr.md next to deck.md; every language of a JSON story), one page per language,
and the export prints one PDF per published language, each the way that language's page shows
the deck (its variant, its title, its lang). Each PDF follows the page's route:
i18n.routing | Default language | Another language (fr) |
|---|---|---|
prefix- (default) | /presentations/ → presentations/ | /fr/ → fr/ |
prefix- | /en/ → en/ | /fr/ → fr/ |
Each one is listed in exports.json with its own route and locale, so the toolbar of the French
page offers the French PDF. With an output pattern, {locale} names the language; a pattern
without it holds the default language's PDF, and each other language's goes under <locale>/ of it
(output: → pdf/ and fr/), so that no two languages
write the same file. The pattern is relative to the build, a leading ./ or / included, for every
language alike ("/ is pdf/ and fr/). --deck lorem
prints every language of that deck.
Language
The PDF speaks the language of the site: metadata.lang of recit.config (else the <html lang> of
its pages, else en). It is the lang of the printed document, so the /Lang of the tagged PDF
that screen readers read, the locale of its entry in exports.json and {locale} in output;
the contents are titled in it ("Sommaire" in French), and so are the page's own labels ("Dernière
modification le…") and the download button ("Télécharger « … » (PDF)").
recit.config.ts
Build the site again after changing it: the pages carry the language the PDF prints.
Options
docs.pdf, checked by DocsPdfOptionsSchema of @recit/core (and by the config JSON Schema, for
an editor). The command line overrides the config.
| Option | Default | What it does |
|---|---|---|
sections | [] | The categories printed: a label, or the route of one of their pages (--section) |
scope | section | section: one PDF per category; page: one PDF per page of those categories (--scope) |
page.size | A4 | A4, A5, A3, A2, Letter or { width, height } (--page-size) |
page.margins | 20mm top and bottom, 24mm left and right | One length, or one per side |
titlePage | false | A first page with the section's title and the site's |
toc | false | Contents after the title page, as links: true lists the pages and their h2, { depth: n } deeper |
header | none | { start, center, end }, with {title}, {page}, {pages} |
footer | { start: | The same tokens; {} removes it |
colorMode | light | light or dark: the pages render in it, Mermaid included (--color-mode) |
output | pdf/ | File name in the build: {slug} of the section or page, {locale}, {format} (-o for one file) |
baseUrl | the site's canonicalUrlOrigin | Where the site is published: a link to a page outside the PDF points there; without it, plain text |
button | true (above the content) | The download button of a page: true or top above, bottom under, false none (not printed) |
outline | true | Bookmarks from the headings |
tagged | true | Tagged PDF, for screen readers |
What the print takes care of
- Only the content. Navigation, sidebars, the page's contents, search, "Copy page", the previous
and next links and the anchors of the headings are left out, and so is anything marked
data-orpagefind- ignore data-.recit- print= "hide" - Diagrams drawn. Each page is printed once nothing in it is still loading: a Mermaid diagram is
awaited until its SVG replaces its spinner, never a fixed delay. Every
idof a page gets the page's prefix, so two diagrams (mermaid-0on each page) keep their own styles. - Pages and sheets. Each page starts on a new sheet; a heading never stays alone at the bottom of a sheet; a table row, a diagram, a picture or a quotation is not split; a table repeats its header row.
- Links. A link to a page of the PDF leads to it inside the file; a link to a page outside it
becomes
baseUrl+ its route, or plain text; an external link stays clickable. - Type and margins. The site's font is embedded; code wraps, and nothing wider than the text (code, table, picture) runs into the margins.