Using a Screenshot API for PDF Generation: A Simpler Alternative to wkhtmltopdf

2026-04-11 | Tags: [screenshot-api, pdf, web-to-pdf, automation]

If you've ever tried to generate PDFs from web pages programmatically, you've probably encountered wkhtmltopdf, Puppeteer's page.pdf(), or one of the many paid PDF generation APIs. They all work, but they come with baggage: binary dependencies, headless browser management, rendering inconsistencies, or monthly fees.

There's a simpler path for many use cases: screenshot the page as a high-resolution image.

When Images Beat PDFs

Not every "I need a PDF" actually needs a PDF. Consider these scenarios:

For these cases, a screenshot API eliminates the entire PDF toolchain:

curl "https://hermesforge.dev/api/screenshot?url=https://example.com/invoice/123&width=1200&scale=2&format=webp" -o invoice.webp

When You Actually Need PDF

If you need: - Selectable text - Multi-page documents - Print-quality output at specific paper sizes - Form fields or annotations

Then yes, you need actual PDF generation. But for everything else, a screenshot at scale=2 (retina resolution) produces output that's visually identical to a PDF when viewed on screen.

The Scale Parameter Makes the Difference

The key to getting print-quality screenshots is the scale parameter. At scale=1, you get screen resolution (96 DPI). At scale=2, you get 192 DPI — close to print quality. The image is 4x the pixel count but renders identically.

# Standard resolution (good for web display)
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&scale=1"

# Retina resolution (good for printing or zooming)
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&scale=2"

A 1200px-wide page at scale=2 produces a 2400px-wide image. That's enough resolution for an A4 print at 200 DPI.

Automating Invoice Screenshots

Here's a practical example: generating invoice images from a web-based invoicing system.

import requests
from datetime import datetime

def capture_invoice(invoice_id, api_key=None):
    """Capture an invoice page as a high-resolution image."""
    params = {
        "url": f"https://yourapp.com/invoices/{invoice_id}",
        "width": 800,      # A4-ish proportion
        "scale": 2,         # Retina quality
        "format": "png",    # Lossless for text
        "delay": 1000,      # Wait for fonts to load
        "block_ads": "true"  # Clean output
    }
    headers = {}
    if api_key:
        headers["X-API-Key"] = api_key

    resp = requests.get(
        "https://hermesforge.dev/api/screenshot",
        params=params,
        headers=headers
    )
    resp.raise_for_status()

    filename = f"invoice_{invoice_id}_{datetime.now():%Y%m%d}.png"
    with open(filename, "wb") as f:
        f.write(resp.content)
    return filename

Batch Processing with the Batch Endpoint

If you need to capture multiple pages at once — say, all invoices for the month — the batch endpoint handles up to 10 URLs per request:

import requests

def capture_invoices_batch(invoice_ids, api_key):
    """Capture multiple invoices in a single API call."""
    urls = [f"https://yourapp.com/invoices/{id}" for id in invoice_ids]

    resp = requests.post(
        "https://hermesforge.dev/api/screenshot/batch",
        json={
            "urls": urls,
            "width": 800,
            "scale": 2,
            "format": "png"
        },
        headers={"X-API-Key": api_key}
    )
    return resp.json()

Comparison: Screenshot vs. PDF Generation

Factor Screenshot API wkhtmltopdf Puppeteer pdf()
Dependencies None (HTTP API) Binary install Node.js + Chromium
Setup time 0 minutes 10-30 minutes 5-15 minutes
Rendering engine Chromium (current) WebKit (outdated) Chromium (current)
CSS Grid/Flexbox Full support Partial Full support
Output format PNG, WebP, JPEG PDF PDF
Text selectable No Yes Yes
Multi-page No Yes Yes
Server resources None (remote) CPU + RAM CPU + RAM

The Pragmatic Choice

If your use case is "I need a visual record of this web page," a screenshot API is simpler, faster to integrate, and requires zero infrastructure. If your use case is "I need a printable, multi-page document with selectable text," use a proper PDF generator.

Most developers default to PDF because it feels more "professional." But for automated reports, monitoring dashboards, and email attachments, a high-resolution screenshot is often the better choice. It's one HTTP call, no dependencies, and the output looks exactly like what you see in the browser.

Try it without an API key:

curl "https://hermesforge.dev/api/screenshot?url=https://example.com&scale=2&format=webp" -o page.webp

For higher rate limits and batch access, get a free API key.