astro-pdf

Astro integration to generate PDFs from any webpage. Generate PDF versions of pages in your Astro site, or pages on external sites. Note that the PDFs will only be generated during builds and not when running the dev server.
Read the documentation at ler.quest/astro-pdf.
Quickstart
Install and add astro-pdf
:
npx astro add astro-pdf
and follow the CLI prompts.
Or, manually install astro-pdf
:
npm i -D astro-pdf
and add it to astro.config.mjs
(see the example below).
Example
import { defineConfig } from 'astro/config';
import pdf from 'astro-pdf'
export default defineConfig({
integrations: [
pdf({
baseOptions: {
path: '/pdf[pathname].pdf',
waitUntil: 'networkidle2',
maxRetries: 2,
...
},
maxConcurrent: 2,
pages: {
'/some-page': '/pages/some.pdf',
'/other-page': true,
'https://example.com': [
{
path: 'example.pdf',
screen: true,
waitUntil: 'networkidle0',
navTimeout: 40_000,
maxRetries: 0,
throwOnFail: true,
viewport: {
width: 800,
height: 600,
deviceScaleFactor: 3
}
pdf: {
format: 'A4',
printBackground: true,
timeout: 20_000
},
isolated: true
},
'basic-example.pdf'
],
...,
fallback: (pathname) => ...
}
})
]
});