TheDocumentation Index
Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
Use this file to discover all available pages before exploring further.
response_type=pdf parameter tells ZenRows to render the target page and return it as a PDF file instead of HTML. The result is a pixel-perfect snapshot of the page as it appears in a browser, including styles, images, and JavaScript-rendered content.
This is useful when you need to archive pages, generate reports, produce shareable snapshots, or feed visual page content into document processing pipelines.
How it works
PDF generation always requires a full browser render. When you addresponse_type=pdf to your request, ZenRows automatically enables JavaScript rendering and captures the fully rendered page as a PDF. You must include js_render=true explicitly in your request for the PDF response to work.
The returned binary content is a standard PDF file that you can save to disk, upload to storage, or pass directly to a document processing tool.
Basic usage
Addresponse_type=pdf and js_render=true to your request parameters:
Saving the PDF to disk
The API returns the PDF as binary content. Useresponse.content (not response.text) to write it correctly to a file:
Python
When to use PDF response
PDF response is the right choice when you need a visual, printable, or archivable snapshot of a page. It works well for:- Page archiving: capture a timestamped visual record of a page’s content and layout.
- Report generation: convert data-rich pages, dashboards, or invoices into portable PDF documents.
- Compliance and auditing: preserve the rendered state of a page as it appeared at a specific point in time.
- Document pipelines: feed rendered page snapshots into PDF processing tools, OCR engines, or document management systems.
- Sharing and distribution: generate a shareable, print-ready version of a page without requiring the recipient to visit the URL.
If you need to extract text or structured data from the page rather than a visual snapshot, use
response_type=markdown, response_type=plaintext, or the outputs parameter instead.Best practices
Always includejs_render=true: PDF generation requires a full browser render. Requests without
js_render=true will not return a valid PDF.
Use wait or wait_for for pages with delayed content: If the page loads content after the initial render (lazy-loaded images, deferred scripts), use
wait (milliseconds) or wait_for (CSS selector) to ensure the full page is visible before the PDF is captured.
Save as binary, not text: PDF files are binary. Always write the response body in binary mode (for example,
"wb" mode in Python and Ruby, Buffer in Node.js, FileOutputStream in Java). Writing binary content as text will produce a corrupt file.
Credits are charged on successful responses: A request using
response_type=pdf is charged when the API returns a 200 status code, regardless of whether the PDF contains the content you expected. Because js_render=true is required, the JS rendering credit cost also applies. Test on a small set of URLs before running at scale.
Troubleshooting
The PDF is blank or missing content
The PDF is blank or missing content
The page likely loads content after the initial render. Add
wait (in milliseconds) to give the page time to finish loading, or use wait_for with a CSS selector that is only present once the main content is visible. Also confirm that js_render=true is included in the request.The saved PDF file is corrupted or unreadable
The saved PDF file is corrupted or unreadable
You are likely writing the response as text instead of binary. Always use binary write mode in your language of choice (
"wb" in Python and Ruby, Buffer in Node.js, FileOutputStream in Java) and write the raw response body. PDF is a binary format and writing it as text will corrupt the file.I'm getting an error when combining response_type=pdf with outputs
I'm getting an error when combining response_type=pdf with outputs
These two parameters are mutually exclusive.
response_type=pdf returns a rendered PDF of the full page, while outputs performs targeted data extraction from the HTML. You can only use one per request.The PDF does not include images or styles
The PDF does not include images or styles
This usually happens when external resources (stylesheets, images, fonts) fail to load during the render. Make sure the target URL is publicly accessible and that
js_render=true is included. If the page uses resources that require authentication, those assets may not render correctly.Pricing
Theresponse_type=pdf parameter is included at no additional cost beyond the standard JS rendering rate. Because PDF generation requires js_render=true, all PDF requests are billed at the JS rendering credit rate. You only pay extra for Premium Proxy when used.
FAQ (Frequently Asked Questions)
Is js_render=true required for PDF response?
Is js_render=true required for PDF response?
Yes. PDF generation requires a full browser render. You must include
js_render=true in every request that uses response_type=pdf. Requests without it will not return a valid PDF.Does response_type=pdf cost more credits?
Does response_type=pdf cost more credits?
PDF requests are billed at the JS rendering credit rate because
js_render=true is required. The response_type=pdf parameter itself does not add an extra cost beyond that.Can I use response_type=pdf with the Scraping Browser?
Can I use response_type=pdf with the Scraping Browser?
No,
response_type=pdf is a parameter of the Universal Scraper API. It is not available in Scraping Browser (CDP/Playwright) sessions. In a Scraping Browser session, you can generate PDFs using Playwright’s built-in page.pdf() method directly in your script.Can I control the PDF page size or orientation?
Can I control the PDF page size or orientation?
Not currently. The PDF is generated using the browser’s default page settings. If you need specific page dimensions or orientation, consider post-processing the PDF with a library like
pypdf or reportlab after saving it.Can I use response_type=pdf to capture paginated content?
Can I use response_type=pdf to capture paginated content?
The PDF captures a single page render. For paginated content, you would need to make a separate request for each URL or page state you want to capture, then combine the resulting PDFs if needed.