Skip to content

PDFs

Updated View as Markdown

Use the running session’s returned CDP connection and Chromium’s Page.printToPDF for the page you control. There is no separate native PDF HTTP endpoint.

// client is an already connected, page-scoped CDP session.
const {data} = await client.send("Page.printToPDF", {
  printBackground: true, preferCSSPageSize: true
});
await writeFile("page.pdf", Buffer.from(data, "base64"));

Import writeFile from node:fs/promises in a Node.js program. The base64 result belongs to your automation process; it is not a signed download URL. Review the page and its permissions before capturing sensitive content.

See Create a browser session and the Browsers API for authentication, request fields, and limits.

Type to search…

↑↓ navigate↵ selectEsc close