Web export
The astro-slides export command turns a deck into a shareable artifact. Three
web formats are supported — a single PDF, one PNG per slide, or a self-contained
offline HTML bundle — all driven by the same command:
astro-slides export --format pdf # single PDF, one page per slideastro-slides export --format png # one image per slideastro-slides export --format html # offline SPA bundle (zip)--format defaults to pdf. The command builds the deck, starts a preview
server, and (for PDF/PNG) drives a headless Chromium browser to render each
slide.
astro-slides export --format pdfProduces a single PDF with one page per slide. Every click step is revealed,
so animated builds appear fully expanded in the output. The default file is
<deck>.pdf in the project directory.
Under the hood the PDF is rendered from the deck’s /print/<deck> route (see
The /print route below), which stacks all slides as
page-sized blocks, then sliced to the requested range with pdf-lib.
Useful PDF-only flags:
--with-toc— add a PDF outline (bookmarks) built from slide titles.--per-slide— write one PDF file per slide instead of a single document. When set,--outputis treated as a directory. Note that splitting drops cross-slide links.--scale <n>— render scale.
# A5-range PDF with a table of contentsastro-slides export --format pdf --range 1-10 --with-toc --output intro.pdf
# One PDF per slide into ./handout/astro-slides export --format pdf --per-slide --output handout/astro-slides export --format pngProduces one PNG image per slide. Images are captured from each slide’s
?embed=1 page (chrome-free — see ?embed=1). The default output
is a <deck>-png/ directory.
Useful PNG-only flags:
--with-clicks— emit one image per click step, so animated builds export as a frame sequence.--scale <n>— device-pixel-ratio for the screenshots (default2, i.e. 2× resolution).--omit-background— transparent background instead of the deck background.
# High-res PNGs of slides 3-5, one frame per click stepastro-slides export --format png --range 3-5 --with-clicks --scale 3 --output frames/astro-slides export --format htmlZips the built dist/ into a single offline HTML bundle (default dist.zip).
The bundle is a self-contained SPA — open index.html in a browser with no
server required. This format does not use Playwright.
astro-slides export --format html --output my-deck.zipCommon flags
Section titled “Common flags”These apply across the web formats:
| Flag | Applies to | Purpose |
|---|---|---|
--format <fmt> | all | pdf | png | html (default pdf). |
--output <path> | all | Output file (pdf / html / single pdf) or directory (png / --per-slide pdf). |
--range "1,3-5,8" | pdf, png | Subset of slides to include (see below). |
--dark | pdf, png | Force the dark color scheme. |
--executable-path <path> | pdf, png | Use your own Chromium binary instead of Playwright’s. |
--range
Section titled “--range”--range accepts a Slidev-style spec: a comma-separated list of slide numbers
and inclusive ranges. Slides are 1-indexed. Out-of-bounds and duplicate entries
are ignored, and the result is sorted.
astro-slides export --format pdf --range "1,3-5,8"Exports slides 1, 3, 4, 5, and 8.
The /print route
Section titled “The /print route”Every deck exposes a /print/<deck> route that renders all slides stacked as
page-sized blocks, one per page, with all click steps revealed. This is the
page PDF export renders (once) before slicing to the requested range with
pdf-lib. It reuses the deck’s own layouts and components, so the print output
matches the live deck. You can open it in a browser and use the browser’s own
“Print → Save as PDF” as a manual alternative to the CLI.
Embed mode
Section titled “Embed mode”Appending ?embed=1 to a slide URL adds an .as-embed class that hides
presentation chrome (help overlay, status bar, drawing tools) while keeping the
slide navigable. PNG export screenshots these embed pages so exported images are
free of UI chrome. ?embed=1 is also handy for embedding a live slide in an
<iframe>.
Source
Section titled “Source”packages/cli/src/main.ts— theexportcommand plusparseRange,slideUrl,printUrl,discoverDecks,exportDeckPdf,exportDeckPng, andzipDirectory(web-export pipeline is self-contained in the CLI).packages/cli/package.json—@playwright/testdeclared as an optional peer.packages/core/src/routes/print.astro— the stacked/print/<deck>page.packages/client/src/styles/print.css— page sizing + reveal-all-clicks.packages/core/src/integration.ts—/,/print, and the404.htmlbuild hook.docs/built/12-export-web.md— phase notes.docs/architecture/cli.md— full CLI flag surface.