ScreenshotAPI allows you to convert web content into high-quality PDFs with full control over layout and structure. Whether you need to html to pdf, url to pdf, or convert website to pdf, the API renders the page in a real browser environment and generates an accurate PDF output. This works for both live URLs and raw HTML, making it a flexible solution for use cases like save webpage as PDF, reporting, archiving, or building an online PDF converter workflow.
You can configure multiple PDF-specific options to match your exact requirements. These include page formats (A4, A3, Letter, etc.), landscape or portrait orientation, and custom page ranges to export only selected sections. The rendering engine ensures proper handling of styles, fonts, and dynamic content, so even complex layouts are preserved. This makes it ideal for generating professional documents, invoices, reports, or snapshots of full webpages with precision and consistency.
You can also combine PDF generation with the full set of rendering features provided by ScreenshotAPI. When you set file_type = pdf, all advanced options remain available and work seamlessly during the rendering process. This includes capabilities such as delay for waiting on dynamic content, lazy_load for loading images and assets, custom JavaScript and CSS injection for modifying page behavior or styling, and options like no_cookie_banners to remove unwanted UI elements. This ensures that your final PDF output is clean, fully loaded, and tailored exactly to your requirements, even for complex or highly interactive web pages.
Parameter Name : format
This parameter defines the paper size used when generating PDF output. It controls how the final PDF is structured in terms of standard page dimensions, ensuring consistency for printing or document-based workflows.
The page dimensions are determined in the following order of priority:
If format is provided - the PDF is generated using the selected standard paper size.
If format is not provided but width and height are specified - those values are used for page dimension.
If none are provided - the entire webpage is rendered as a single long PDF page without page breaks.
Use this parameter when you need your PDF to match standard document sizes.
Example: Generating invoices, reports, or contracts that need to be printed on A4 or Letter paper.
Use default behavior when you want a full-page continuous PDF.
Example: Archiving long webpages like blogs or documentation as a single scrollable PDF without page breaks.
Default value:' '.
Parameter Name : page_range
It allows you to define a specific range of pages to include in the generated PDF output. Only the pages within the specified range are retained, while all other pages are excluded from the final pdf document.
For example, if a webpage renders into 10 pages and you set page_range to 2-6, the resulting PDF will contain only 5 pages (2 through 6).
The value must be provided as a string in the format: 'start-end'
where:
start = starting page number (positive integer)
end = ending page number (positive integer)
start ≤ end
"1-3" - Includes pages 1, 2, and 3
"2-6" - Includes pages 2, 3, 4, 5, and 6
"5-5" - Includes only page 5
Use this parameter when you only need a specific portion of a multi-page PDF.
Example: Extracting only the pricing or summary section from a long generated report.
Use this for selective document exports.
Example: Archiving long Skipping cover pages and exporting only the main content pages (e.g., pages 2–10).
Page range is applied after full rendering, meaning all pages are generated first and then trimmed to the specified range.
If the end value exceeds the total number of pages, the PDF will include pages from start up to the last available page.
This parameter has no effect when the output is a single-page PDF (i.e., when format is not set and no width/height is provided).
Default value:' '.
Parameter Name : landscape
It controls the orientation of the generated PDF. When enabled, the page is rotated by 90 degrees, switching the width and height of the selected page format.
For example, if the page format is set to A4 (210 × 297 mm in portrait), enabling landscape will render the PDF as 297 × 210 mm.
true: Generates the PDF in landscape orientation (wider than tall).
false: Generates the PDF in portrait orientation (taller than wide).
Use true when the content is horizontally wide and does not fit well in a vertical layout.
Example: Exporting analytics dashboards or wide data tables where columns would otherwise be cut off or wrapped in portrait mode.
Use false when standard document formatting is required.
Example: Creating invoices, letters, or reports where a traditional vertical page layout is expected.
Default value:false (portrait orientation).
Parameter Name : custom_html
This parameter allows you to pass raw HTML content directly as a string instead of providing a URL. The PDF is generated from the supplied HTML markup, completely bypassing any URL-based fetching. This is especially useful when working with locally generated content, private pages, or dynamically created HTML that is not publicly accessible.
Passing the above HTML as the value of custom_html will generate a PDF directly from that markup.
Use this parameter when your webpage is not publicly available.
Example: Converting a locally built HTML page into a PDF during development without hosting it online.
Use this for secure or restricted environments.
Example: Rendering content that exists behind a firewall or private network where external access is not possible.
When custom_html is provided, the url parameter is ignored HTML content takes full precedence.
All other PDF-related parameters such as format, landscape, and page_range remain fully compatible and apply normally.
Inline CSS and JavaScript included in the HTML will be applied during rendering.
It is recommended to use a POST request when sending custom_html, as GET requests have character length limitations that may truncate large HTML content.
Default value:' '.