HTML to PDF API

Convert Any URL or Web Page to PDF — One API Call

Published April 4, 2026 — 7 min read

URLSnap's PDF API converts any publicly accessible URL to a pixel-perfect PDF using a real headless Chromium browser. No wkhtmltopdf, no Puppeteer to host, no server to maintain — just a single GET request.

The Quickest Way to Try It

curl "https://urlsnap.dev/api/pdf?url=https://example.com&apiKey=YOUR_KEY" \
  --output page.pdf

That's it. Open page.pdf and you'll see a rendered PDF of the page, with JavaScript executed and CSS applied.

Code Examples

Node.js
Python
PHP
Go
// Node.js — save a URL as PDF
const fs = require('fs');

async function urlToPdf(url, outputPath) {
  const apiKey = 'YOUR_API_KEY';
  const endpoint = `https://urlsnap.dev/api/pdf?url=${encodeURIComponent(url)}&apiKey=${apiKey}&format=A4`;

  const res = await fetch(endpoint);
  if (!res.ok) throw new Error(`API error: ${res.status}`);

  const buffer = Buffer.from(await res.arrayBuffer());
  fs.writeFileSync(outputPath, buffer);
  console.log(`Saved PDF: ${outputPath}`);
}

urlToPdf('https://example.com', 'output.pdf');
# Python — save a URL as PDF
import requests
from urllib.parse import quote

def url_to_pdf(url, output_path):
    api_key = 'YOUR_API_KEY'
    endpoint = (
        f"https://urlsnap.dev/api/pdf"
        f"?url={quote(url)}&apiKey={api_key}&format=A4"
    )
    response = requests.get(endpoint)
    response.raise_for_status()

    with open(output_path, 'wb') as f:
        f.write(response.content)
    print(f"Saved PDF: {output_path}")

url_to_pdf('https://example.com', 'output.pdf')
<?php
// PHP — save a URL as PDF
function urlToPdf($url, $outputPath) {
    $apiKey = 'YOUR_API_KEY';
    $endpoint = 'https://urlsnap.dev/api/pdf?url='
        . urlencode($url)
        . '&apiKey=' . $apiKey
        . '&format=A4';

    $pdf = file_get_contents($endpoint);
    if ($pdf === false) throw new Exception('API request failed');

    file_put_contents($outputPath, $pdf);
    echo "Saved PDF: {$outputPath}\n";
}

urlToPdf('https://example.com', 'output.pdf');
// Go — save a URL as PDF
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
)

func urlToPDF(targetURL, outputPath string) error {
    apiKey := "YOUR_API_KEY"
    endpoint := "https://urlsnap.dev/api/pdf?url=" +
        url.QueryEscape(targetURL) +
        "&apiKey=" + apiKey + "&format=A4"

    resp, err := http.Get(endpoint)
    if err != nil { return err }
    defer resp.Body.Close()

    file, _ := os.Create(outputPath)
    defer file.Close()
    io.Copy(file, resp.Body)

    fmt.Printf("Saved PDF: %s\n", outputPath)
    return nil
}

Common Use Cases

📄 Invoice & Report Generation

Render your HTML invoice template as a PDF. Perfect for billing systems and automated reports.

📰 Content Archiving

Save articles, documentation pages, or web content as PDFs for offline storage or distribution.

🖨 Print-Ready Exports

Let users export any page of your web app as a print-ready PDF — no browser print dialog needed.

📊 Dashboard Snapshots

Capture analytics dashboards, reports, or data visualizations as PDFs for sharing with stakeholders.

📋 Contract & Document Signing

Convert HTML contract templates to PDF before sending them to e-signature services.

📚 Documentation Export

Export documentation pages to PDF for users who prefer offline reading or printing.

API Parameters

GET https://urlsnap.dev/api/pdf

# Required
url=https://example.com     # URL to convert to PDF
apiKey=YOUR_API_KEY         # from urlsnap.dev/#get-key

# Optional
format=A4                   # A4 (default), Letter, Legal, A3, A5, Tabloid
landscape=true              # landscape orientation (default: portrait)
delay=2000                  # wait N ms after page load (for JS-heavy pages)
Tip: Use delay=2000 or higher if your page loads data asynchronously via JavaScript. The API will wait for the specified time before generating the PDF, ensuring all content is rendered.

Why Use an API Instead of wkhtmltopdf?

wkhtmltopdf is popular but uses an old WebKit engine that doesn't support modern CSS (Grid, Flexbox, CSS Variables) or JavaScript properly. Pages that look great in Chrome often look broken in wkhtmltopdf.

URLSnap uses headless Chromium — the same engine as Google Chrome — so your PDFs look exactly like they do in a browser: modern layouts, web fonts, CSS animations, and JavaScript-rendered content all work correctly.

Pricing

Free
$0/mo
20 req/day
Pro
$29/mo
5,000 req/day

Start converting URLs to PDFs now

Free tier: 20 requests/day, no credit card required. Takes 30 seconds to get your API key.

Get Free API Key See All Plans

Frequently Asked Questions

Does it support JavaScript-heavy pages?

Yes. URLSnap uses a real Chromium browser, so React, Vue, Angular, and other SPA frameworks render correctly. If your page loads data asynchronously, add ?delay=2000 to wait for the content to appear.

What about pages behind authentication?

URLSnap fetches pages as a regular browser would. For public pages it works immediately. For pages requiring login, you'd need to provide a URL that includes an auth token or uses a shareable/public endpoint.

How is the PDF sized?

By default, PDFs are A4 portrait. You can change the format with ?format=Letter, ?format=A3, etc. Use ?landscape=true for landscape orientation.

Can I use this in a serverless environment (AWS Lambda, Vercel)?

Yes — URLSnap is just an HTTP API call. No binaries to install, no system dependencies. Works in any environment that can make outbound HTTP requests.

Is there a rate limit beyond the daily cap?

There's a soft concurrency limit to keep the service stable. For high-volume or burst workloads, the Pro plan ($29/mo) is recommended. Contact support for custom arrangements.