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
| Aspect | DIY (wkhtmltopdf / Puppeteer) | SnapAPI |
|---|---|---|
| Setup | Install Chrome/wkhtmltopdf, manage deps | Zero setup โ API call |
| Font rendering | Install fonts on server, font issues common | Full web font support |
| CSS support | wkhtmltopdf: outdated WebKit; Puppeteer: full | Full modern CSS (Chromium) |
| JavaScript rendering | wkhtmltopdf: limited; Puppeteer: full | Full JS execution |
| Memory usage | 500MB+ per Chrome instance | Zero โ serverless |
| Concurrent generation | Complex queue management | Auto-scaling |
| Print CSS support | Varies by tool | Full @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
- Use
@media printCSS โ hide navigation, ads, and non-essential elements in your print stylesheet - Set
printBackground=trueโ without this, background colors and images won't render - Use proper paper sizes โ US Letter (8.5ร11"), A4 (8.27ร11.69"), or custom dimensions in inches
- Add page breaks โ use
page-break-before: alwaysCSS to control multi-page layouts - Test with web fonts โ ensure your fonts load before the PDF is generated (SnapAPI waits for network idle)
- Use
waitForSelectorโ if your page has dynamic content, wait for a specific element to ensure it's loaded
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