Web Page to PDF API

Convert any URL to a high-quality PDF with a single API call. Chromium rendering preserves CSS, fonts, images, and JavaScript-rendered content exactly as it appears in the browser.

Start Free — 200 PDFs/month

How SnapAPI Converts Web Pages to PDF

SnapAPI loads the target URL in a full Chromium browser, waits for JavaScript execution and all resources to finish loading, then uses Chromium print-to-PDF to generate a PDF that matches the page print stylesheet. The Chromium engine supports the complete CSS print media specification, producing PDFs with accurate typography, color, image rendering, and layout at the configured paper dimensions. Unlike server-side HTML-to-PDF libraries using outdated browser engines, SnapAPI handles modern CSS including Grid, Flexbox, CSS Custom Properties, and web fonts from services like Google Fonts. The resulting PDF faithfully represents the page as designed, without the layout breakage that affects older PDF tools when rendering modern CSS. Authentication-protected pages can be captured by passing the required cookies or headers in the API request, allowing internal dashboard and report pages to be converted to PDF with the same API call.

PDF Endpoint Parameters

The SnapAPI PDF endpoint accepts parameters controlling paper size, margins, orientation, and rendering options. The format parameter accepts A4, Letter, A5, Legal, and Tabloid. The margin_top, margin_bottom, margin_left, and margin_right parameters set page margins in millimeters. The landscape parameter set to true produces landscape PDFs. The print_background parameter set to true preserves background colors and images, essential for branded reports, certificates, and marketing collateral where the design depends on colored backgrounds. The delay parameter waits a specified number of milliseconds after page load before generating the PDF, ensuring JavaScript-rendered content and lazy-loaded images appear in the output. The delay value should be set to match the actual rendering time of your target page: most pages need zero to one thousand milliseconds, while complex dashboards may need two to three thousand.

import requests

API_KEY = "your_api_key"

def webpage_to_pdf(url, output_path, **options):
    params = {
        "url": url,
        "format": options.get("format", "A4"),
        "margin_top": options.get("margin_top", "10mm"),
        "margin_bottom": options.get("margin_bottom", "10mm"),
        "margin_left": options.get("margin_left", "15mm"),
        "margin_right": options.get("margin_right", "15mm"),
        "print_background": "true" if options.get("print_background") else "false",
        "landscape": "true" if options.get("landscape") else "false",
    }
    if options.get("delay"):
        params["delay"] = options["delay"]
    resp = requests.get(
        "https://api.snapapi.pics/pdf",
        params=params,
        headers={"Authorization": f"Bearer {API_KEY}"},
        timeout=60,
    )
    resp.raise_for_status()
    with open(output_path, "wb") as f:
        f.write(resp.content)
    return len(resp.content)

size = webpage_to_pdf(
    "https://example.com/report",
    "report.pdf",
    format="A4",
    print_background=True,
    delay=2000,
)
print(f"PDF size: {size:,} bytes")

Optimizing Pages for PDF Output

Web pages designed for browser viewing often need CSS print media adjustments to produce clean PDF output. Add a @media print stylesheet that hides navigation bars, sidebars, cookie banners, social sharing buttons, and live chat widgets that should not appear in the PDF. Set page-break-inside: avoid on tables, figures, and code blocks to prevent awkward mid-element page breaks. Set page-break-before: always on section headings to start each major section on a new page in long documents. Use the @page CSS rule to define consistent page margins and footer content. Test your print stylesheet by using Chrome File > Print > Save as PDF before deploying, since Chrome print preview closely matches SnapAPI Chromium output and reveals layout issues at actual paper dimensions before you run API calls.

Web Page to PDF Use Cases

Report generation is the highest-volume use case: analytics dashboards, financial reports, and business intelligence summaries are rendered as web pages and converted to PDF for distribution to stakeholders. Invoice generation converts billing pages to PDF for email delivery to customers, providing a professional document format without requiring a separate PDF generation library in your stack. Legal document archiving converts court filings, regulatory pages, and compliance documents to PDF for offline storage and case documentation. Content export in note-taking and knowledge management SaaS products lets users export content to PDF by rendering the content page and converting it to a download. Marketing collateral generation converts HTML email templates and landing pages to PDF for print materials and media kits. Screenshot-plus-PDF workflows use a single SnapAPI key for both image and PDF output of the same URL, eliminating a second service dependency.

Get Started with the Web Page to PDF API

Register at snapapi.pics/register for a free account with two hundred PDF generation requests per month at no cost. No credit card is required to start. The PDF endpoint is available on all plan tiers including the free tier. The SnapAPI documentation at snapapi.pics/docs covers all PDF endpoint parameters with code examples in JavaScript, Python, Go, PHP, Swift, and Kotlin. For applications that need both screenshots and PDFs from the same URL, SnapAPI handles both with a single API key and a single line change in the endpoint path, reducing integration and billing complexity compared to using separate screenshot and PDF services.

Web Page to PDF for Scheduled Report Generation

Automated report generation systems use SnapAPI to convert dashboard and report pages to PDF on a scheduled basis, delivering PDF reports to stakeholders without requiring manual page visits or browser interactions. Implement a scheduled job in your preferred task scheduler that iterates over a list of report page URLs, calls the SnapAPI PDF endpoint for each URL, and stores the resulting PDF files in cloud storage with timestamped filenames for archiving. Trigger the PDF delivery step after all pages have been converted by composing the individual PDFs into a single combined report document or sending each PDF as an email attachment to the configured recipient list. For dashboards that require authentication, pass the session cookie or authorization header in the SnapAPI request so Chromium renders the authenticated dashboard view rather than the login page. Schedule report generation during off-peak hours to avoid competing with interactive user traffic on the dashboard pages being captured.

Web Page to PDF Quality and Fidelity

The fidelity of SnapAPI PDF output compared to the browser view depends primarily on how well the target page implements CSS print media styles. Pages without a print stylesheet render at the configured paper width with the same layout as the screen view, which often produces acceptable PDF output for simple content pages but can cause layout issues for complex dashboard pages designed for wide screens. Adding CSS print media queries to your pages gives you explicit control over PDF layout independent of the screen layout, allowing you to optimize the PDF output without affecting the browser experience. The most impactful print stylesheet changes are hiding interface elements that do not translate to PDF, setting explicit page widths for content containers, and controlling page breaks around tables and figures. For third-party pages you do not control, the SnapAPI PDF output reflects the page as Chromium renders it, and the quality depends on how that page is designed for print.

Combining Web Page to PDF with Screenshot API

Many applications need both screenshot thumbnails and PDF exports of the same pages: a project management tool might display screenshot thumbnails in the project overview and offer PDF export of the full project page, or a competitive intelligence tool might store screenshots for visual comparison and PDFs for archived documentation. SnapAPI handles both formats with a single API key and a single endpoint path change, from /screenshot for PNG or JPEG thumbnails to /pdf for full PDF documents. This unified approach eliminates the need to integrate a separate PDF generation service, maintain two API keys, manage two billing relationships, and handle two sets of error and rate limiting behavior. The screenshot and PDF endpoints share the same authentication, parameter conventions, and error response format, so existing error handling and retry logic from the screenshot integration applies directly to PDF calls without modification.

Web Page to PDF API Pricing and Free Tier

SnapAPI PDF generation is included in all plan tiers with the same request count as screenshot and scrape calls. The free tier provides two hundred requests per month shared across all endpoint types including PDF, screenshot, scrape, and extract, with no credit card required and no expiry on the free allocation. For applications generating PDFs on demand in response to user actions, two hundred monthly requests is sufficient for a low-volume production deployment or a full development and integration testing cycle. The Starter plan at nineteen dollars per month provides five thousand requests per month, and the Pro plan at seventy-nine dollars per month provides fifty thousand requests. For high-volume automated report generation that converts dozens or hundreds of pages to PDF on a scheduled basis, the Pro plan at 0.16 cents per request provides a cost-effective rate for large-scale PDF workflows. Register at snapapi.pics/register to start with the free tier immediately and upgrade when your volume requires it.