Use Case Guide · Updated February 2026

HTML to PDF API: Convert Web Pages to PDF

Generating PDFs from web content is one of the most common developer tasks — and one of the most painful. Invoices, reports, certificates, dashboards — they all need pixel-perfect PDF output from HTML/CSS. Running wkhtmltopdf or headless Chrome yourself means managing servers, dealing with font rendering issues, and fighting CSS print styles. A PDF generation API eliminates all of that.

📄 HTML to PDF in One API Call

Convert any URL or HTML to PDF. Custom sizes, headers, footers. 200 free/month.

Get Free API Key →

Generate PDFs from URLs

curl

curl "https://api.snapapi.pics/v1/pdf?url=https://example.com/invoice/123" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o invoice.pdf

With Custom Options

curl "https://api.snapapi.pics/v1/pdf?url=https://example.com/report&paperWidth=8.5&paperHeight=11&marginTop=1&marginBottom=1&printBackground=true" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o report.pdf

Node.js — Invoice Generation

async function generateInvoice(invoiceId) {
  const response = await fetch(
    `https://api.snapapi.pics/v1/pdf?` +
    `url=${encodeURIComponent(`https://app.yoursite.com/invoices/${invoiceId}`)}` +
    `&paperWidth=8.5&paperHeight=11&printBackground=true`,
    { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
  );

  const pdfBuffer = Buffer.from(await response.arrayBuffer());

  // Save or email the invoice
  await fs.promises.writeFile(`invoices/${invoiceId}.pdf`, pdfBuffer);
  return pdfBuffer;
}

Python — Report Generation

import requests

def generate_report_pdf(report_url, output_path):
    response = requests.get(
        'https://api.snapapi.pics/v1/pdf',
        params={
            'url': report_url,
            'paperWidth': 8.5,
            'paperHeight': 11,
            'marginTop': 0.5,
            'marginBottom': 0.5,
            'printBackground': True
        },
        headers={'Authorization': 'Bearer YOUR_API_KEY'}
    )
    with open(output_path, 'wb') as f:
        f.write(response.content)
    return output_path

# Generate a dashboard PDF
generate_report_pdf('https://app.yoursite.com/dashboard', 'dashboard.pdf')

PDF Generation: API vs DIY

AspectDIY (wkhtmltopdf / Puppeteer)SnapAPI
SetupInstall Chrome/wkhtmltopdf, manage depsZero setup — API call
Font renderingInstall fonts on server, font issues commonFull web font support
CSS supportwkhtmltopdf: outdated WebKit; Puppeteer: fullFull modern CSS (Chromium)
JavaScript renderingwkhtmltopdf: limited; Puppeteer: fullFull JS execution
Memory usage500MB+ per Chrome instanceZero — serverless
Concurrent generationComplex queue managementAuto-scaling
Print CSS supportVaries by toolFull @media print support

Common PDF Generation Use Cases

🧾 Invoices & Receipts

Generate professional invoices from HTML templates. Consistent rendering across all platforms.

📊 Reports & Dashboards

Convert data dashboards to shareable PDFs. Charts, tables, and graphs render perfectly.

📜 Certificates

Generate personalized certificates, diplomas, and awards from templates at scale.

📋 Contracts & Documents

Create legal documents, proposals, and contracts from structured data and templates.

PDF Generation Tips

Advanced: HTML String to PDF

Don't want to host a template page? You can send HTML directly:

curl -X POST "https://api.snapapi.pics/v1/pdf" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<html><body style=\"font-family: Arial; padding: 40px;\"><h1>Invoice #1234</h1><p>Amount: $99.00</p></body></html>",
    "paperWidth": 8.5,
    "paperHeight": 11
  }' \
  -o invoice.pdf

Start Generating PDFs

Convert any webpage or HTML to PDF. No servers to manage.

Get Free API Key →

FAQ

What paper sizes are supported?

Any custom size in inches. Common presets: US Letter (8.5×11"), A4 (8.27×11.69"), Legal (8.5×14"). Set paperWidth and paperHeight parameters.

Can I add headers and footers to PDFs?

Yes. Use the headerTemplate and footerTemplate parameters with HTML. You can include page numbers, dates, and custom text.

Does it support JavaScript-rendered content?

Yes. SnapAPI uses a full Chromium browser, so React, Vue, Angular, and any JavaScript framework renders correctly before PDF generation.

How long does PDF generation take?

Typically 2-5 seconds depending on page complexity. Simple pages are under 2 seconds. Pages with heavy JavaScript or many images take longer.

Related: Free Screenshot API · Web Archiving API · API Documentation

Ready to Get Started?

Start capturing screenshots for free — no credit card required.

Start Free → 200 Screenshots/Month