Webpage to PDF API
Convert a Webpage to PDF with an API
Capture public web pages as PDFs after their JavaScript, fonts, images, and network activity are ready, without maintaining a browser service.
Updated
Key outcomes
Use URLs that the rendering service can reach
The source URL must be reachable from the public internet and return the page without interactive authentication. Avoid short-lived signed links when a conversion may be retried later.
For protected dashboards, intranet pages, or personalized screens, render the equivalent HTML in your own backend and send that HTML as source. The conversion request does not accept arbitrary site cookies or authorization headers.
Never put passwords, session tokens, or API keys in a source URL. URLs can appear in application logs and infrastructure telemetry.
Choose when the page is ready
Dynamic pages may finish their initial navigation before charts, fonts, or lazy images are visible. Combine the smallest set of timing controls that matches the page behavior.
- Set wait_for_network when data loads immediately after navigation.
- Enable lazy_load_images for pages that defer off-screen images.
- Use delay for a bounded animation or chart-rendering window.
- Set timeout so a broken page cannot occupy a worker indefinitely.
Send the conversion request
This server-side example waits for network activity, gives late UI work a short window, and injects CSS that removes navigation from the PDF.
const response = await fetch('https://api.pixeltopdf.com/convert/pdf', {
method: 'POST',
headers: {
'X-API-Key': process.env.PIXELTOPDF_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
source: 'https://example.com/public-report',
format: 'A4',
wait_for_network: true,
lazy_load_images: true,
delay: 800,
timeout: 45,
css: 'nav, .cookie-banner { display: none !important; }',
}),
});
if (!response.ok) throw new Error(`Conversion failed: ${response.status}`);
const pdf = await response.arrayBuffer();Keep webpage exports stable
A webpage built for screens may have sticky elements, infinite scrolling, or responsive breakpoints that do not translate cleanly to paper. Add a print stylesheet to the source page when you control it, or use the css option for conversion-only adjustments.
Test empty data, error banners, long tables, cookie notices, and slow assets. A successful HTTP status only confirms that a file was generated; your integration should also test the content states your users can produce.
Frequently asked questions
Can PixelToPdf convert a login-protected page?
The conversion endpoint does not accept arbitrary browser cookies or site authorization headers. Render private content as HTML in your own authenticated backend and send that HTML instead.
Does webpage conversion execute JavaScript?
Yes. JavaScript runs by default in Chromium. You can disable it when it is unnecessary or use timing controls for client-rendered content.
How can I remove menus and cookie banners?
Use your page print stylesheet or send CSS in the request to hide selectors that should not appear in the PDF.
Continue building
Build your first conversion
Start with 75 free credits each month. No credit card required.