Convert a web page or HTML to PDF
generate_pdfConvert any URL or raw HTML into a hosted PDF using a real browser. Set paper size, orientation, and page ranges to turn web pages into printable documents.
Instructions
Renders a URL or raw HTML in a real browser and converts it to a PDF, returning the hosted PDF URL. Choose a paper size ('format') for paginated output; without format (and without width/height) the whole page becomes one long continuous PDF page. Supports landscape, page ranges, print backgrounds, print vs screen CSS, and all page preparation options (delay, lazy_load, ad/cookie-banner blocking, CSS/JS injection). Use save_path to save the PDF locally.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| js | No | JavaScript executed in the page before capture, e.g. "document.querySelector('.popup').remove();". | |
| css | No | CSS injected before capture, e.g. '.header { display: none; }'. | |
| ttl | No | Cache lifetime in seconds when enable_caching is true. Default 2592000 (30 days). | |
| url | No | Website URL to render, including the protocol, e.g. 'https://example.com'. Either url or custom_html is required. | |
| byob | No | Save the output to your own bucket configured under Storage Integrations in the dashboard (Bring Your Own Bucket). Default false. | |
| block | No | Resources to block while rendering. For a clean capture use ['ads', 'cookie_banners', 'chat_widgets']. 'tracking' blocks analytics. 'javascript', 'stylesheets', 'xhr', and 'fetch' can break pages or hide content — use only when needed. Others: images, media (audio/video), fonts, text_tracks, event_source, websockets, manifest. | |
| delay | No | Extra wait in milliseconds after the page loads, before capture. Default 0. Use 1000-5000 for animations, charts, or late-loading content. | |
| fresh | No | true (default) always renders a new capture; false returns a cached capture when one exists from a request with enable_caching=true and identical parameters. | |
| media | No | CSS media type to emulate: 'print' uses the site's print stylesheet, 'screen' matches what a visitor sees. | |
| proxy | No | Proxy to route the request through: 'address:port' or 'username:password@address:port' (an http:// prefix is accepted). Useful for geo-specific content or CAPTCHA-prone sites. | |
| width | No | Browser viewport width in pixels (max 7680). Default 1680. Use ~390 to emulate a phone, ~768 for a tablet. | |
| format | No | Paper size. A4 or Letter for documents and invoices. Omit for a single continuous page. | |
| height | No | Browser viewport height in pixels (max 4320). Default 876. | |
| js_url | No | URL of an external JavaScript file to execute before capture. | |
| cookies | No | Cookies to set before loading, as 'name=value; other=value;'. Use for pages behind a login. | |
| css_url | No | URL of an external stylesheet to inject before capture. | |
| headers | No | Extra HTTP headers as 'Name: value;' pairs separated by semicolons, e.g. 'Authorization: Bearer abc; X-Test: 1;'. | |
| timeout | No | Maximum milliseconds the API waits for the page to load before aborting. Default 100000. | |
| latitude | No | Latitude reported by the browser Geolocation API. | |
| timezone | No | IANA timezone to emulate, e.g. 'America/New_York', 'Asia/Karachi'. Default is the server timezone. | |
| dark_mode | No | Render with the dark color scheme (for sites that support it). Default false. | |
| grayscale | No | Desaturate the output, 0 (full color, default) to 100 (fully grayscale). | |
| landscape | No | Landscape orientation — good for wide tables and dashboards. Default false (portrait). | |
| lazy_load | No | Scroll through the whole page first so lazy-loaded images and sections render. Default false. | |
| longitude | No | Longitude reported by the browser Geolocation API. | |
| save_path | No | Optional local path to also save the file to, e.g. './shots/home.png'. A directory path (ending in '/' or an existing directory) keeps the remote file name. Relative paths resolve against the MCP server's working directory. | |
| adjust_top | No | Scroll the viewport down this many pixels before capture. Default 0. Not supported for PDFs. | |
| page_range | No | Keep only these pages, as 'start-end', e.g. '1-3' or '5-5'. Needs a paginated PDF (format or width/height). | |
| user_agent | No | Custom User-Agent string, e.g. a mobile Safari UA to get the mobile site. | |
| bucket_name | No | Bucket to use with byob when several are configured under the same service. | |
| custom_html | No | Raw HTML to render instead of loading a URL. Takes precedence over url. Inline CSS and JavaScript in the HTML are applied. Useful for pages that are not publicly reachable. | |
| template_id | No | ID of a saved cookie template from the ScreenshotAPI dashboard to apply before navigation. | |
| scroll_delay | No | Milliseconds to wait between scroll steps when lazy_load is true. Default 500. High values on long pages can hit the timeout. | |
| blur_selector | No | CSS selector(s) of elements to blur, comma-separated — for redacting emails, account numbers, or other sensitive data. | |
| enable_caching | No | Store this capture in the cache for reuse. Cached captures served later (with fresh=false) do not consume credits. Default false. | |
| wait_for_event | No | Page lifecycle event to wait for before capture. 'load' (default) waits for all resources; 'domcontentloaded' is faster but may miss images; 'networkidle' waits until no network requests for 500ms — best for SPAs and dashboards. | |
| click_recursion | No | How many times to click selector_to_click in sequence. Requires selector_to_click. Default 0. | |
| remove_selector | No | CSS selector(s) of elements to remove from the page before capture, comma-separated, e.g. '.ad-banner, #sidebar'. Non-matching selectors are ignored. | |
| storage_service | No | Storage service to use with byob when several are configured: 'aws', 'wasabi', or 'google_cloud'. | |
| accept_languages | No | Accept-Language header for localized content, e.g. 'fr-FR,fr;q=0.9'. Default 'en-US,en;q=0.8'. | |
| enable_incognito | No | Render in an isolated incognito session with no persisted cookies or storage. Default false. | |
| print_background | No | Include background colors and images in the PDF. | |
| result_file_name | No | Custom file name for the stored output. Non-unique names can overwrite earlier files. | |
| scroll_to_element | No | CSS selector of an element to scroll into view before a viewport capture. | |
| selector_to_click | No | CSS selector of an element to click before capture, e.g. to open a tab, dropdown, or accordion. | |
| block_specific_requests | No | Specific request URLs or patterns to block, separated by commas, spaces, or newlines, e.g. 'https://example.com/api/data, https://ads-domain.com'. |