Get PDF
AI-generatedSummary
Generate a PDF from a webpage loaded via CDP, returning binary data in a named property and navigation metadata as JSON.
Inputs
- cdpEndpoint (required) — The CDP endpoint URL to connect to the remote browser. Can be HTTP or WebSocket URL (e.g., http://localhost:9222 or ws://localhost:9222/devtools/browser/xxx). Default: http://localhost:9222.
- authentication — Authentication method for the CDP connection. Options: None (default) or HTTP Basic Auth.
- url (required) — The URL of the page to print as PDF.
- dataPropertyName (required) — Name of the binary property in which to store the PDF data. Default: data.
- pageRanges — Paper ranges to print, e.g. 1-5, 8, 11-13.
- scale — Scales the rendering of the web page. Amount must be between 0.1 and 2. Default: 1.
- preferCSSPageSize — Give any CSS @page size declared in the page priority over width, height, or format option. Default: true.
- format — Valid paper format types when printing a PDF. Shown when preferCSSPageSize is false. Options include Letter, A4, A5, etc. Default: Letter.
- height — Sets the height of paper. Can be a number or a string with a unit. Shown when preferCSSPageSize is false.
- width — Sets the width of paper. Can be a number or a string with a unit. Shown when preferCSSPageSize is false.
- landscape — Whether to print in landscape orientation. Default: true.
- margin — Set the PDF margins. Contains optional top, bottom, left, right string properties.
- displayHeaderFooter — Whether to show the header and footer. Default: false. Shown for getPDF operation.
- headerTemplate — HTML template for the print header. Used when displayHeaderFooter is true.
- footerTemplate — HTML template for the print footer. Used when displayHeaderFooter is true.
- omitBackground — Hides default white background and allows generating PDFs with transparency. Default: false.
- printBackground — Set to true to include background graphics. Default: false.
- queryParameters — The query parameter to send.
- options — Additional options including fileName (applies to Get PDF and Get Screenshot), timeout, viewport dimensions, user agent, locale, timezone, geolocation, and more.
Output shape
array of items, each containing:
Binary data stored in the property specified by dataPropertyName with MIME type application/pdf. JSON metadata includes response headers, HTTP status code, and final URL after navigation.
Examples
Example 1: Generate a PDF of https://example\.com and store the binary data in the property 'myPdf'.
Set URL to https://example.com, dataPropertyName to myPdf, leave other options at defaults.