Skip to content

clause-netizen/snappdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

SnapPDF — URL to PDF API

Convert any webpage (or raw HTML) to a PDF with a single API call. SnapPDF renders the page in headless Chromium — CSS, web fonts, and backgrounds included — and returns the PDF bytes. No headless Chrome for you to run, scale, or patch.

HTML to PDF · URL to PDF · webpage to PDF · invoice/receipt PDF · save webpage as PDF

🔗 Live demo + docs: https://snappdf.dedyn.io:8444Get an API key (free tier): available on RapidAPI — see the demo page for the link.


Quick start

Every call is GET /v1/pdf?url=<page> with your RapidAPI key. The response is application/pdf bytes.

Set RAPIDAPI_HOST to the exact host shown on your RapidAPI listing → Endpoints → Code Snippets (it looks like snappdf.p.rapidapi.com).

Node.js

const fs = require("fs");
const HOST = "snappdf.p.rapidapi.com";            // copy the exact host from your listing
const url  = "https://example.com";
const res  = await fetch(`https://${HOST}/v1/pdf?format=A4&url=${encodeURIComponent(url)}`, {
  headers: { "X-RapidAPI-Key": process.env.RAPIDAPI_KEY, "X-RapidAPI-Host": HOST },
});
fs.writeFileSync("out.pdf", Buffer.from(await res.arrayBuffer()));

Python

import os, requests, urllib.parse
HOST = "snappdf.p.rapidapi.com"
url  = "https://example.com"
api  = f"https://{HOST}/v1/pdf?format=A4&url=" + urllib.parse.quote(url)
r = requests.get(api, headers={"X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"], "X-RapidAPI-Host": HOST})
open("out.pdf", "wb").write(r.content)

curl

curl "https://snappdf.p.rapidapi.com/v1/pdf?url=https://example.com&format=A4" \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: snappdf.p.rapidapi.com" \
  --output out.pdf

More runnable examples (PHP, Go, Ruby) are in examples/.

Parameters

Param What it does
url the http(s) page to render (required)
format A4 (default), A3, A5, Letter, Legal, Tabloid
landscape true for landscape orientation
scale zoom factor 0.12
background false to omit CSS backgrounds
wait_for_selector CSS selector to wait for before printing (for JS-rendered content)

Common use cases

  • Invoices & receipts — render your HTML invoice at a URL, get a print-ready PDF.
  • Save / archive webpages as PDF at scale.
  • Reports & dashboards exported to PDF on demand.

FAQ

Does it run JavaScript on the page? Yes — it's real Chromium, so client-side JS runs before printing. Use wait_for_selector for content that loads after the initial render.

Do I have to run headless Chrome? No. That's the point — SnapPDF runs it for you; you make one HTTP request.


MIT licensed. Built by the SnapPDF team. Issues & PRs welcome.

About

URL to PDF API — convert any webpage or HTML to PDF in one call (headless Chromium). Node, Python, PHP, curl examples.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors