Quickstart
From an API key to a PDF in three steps.
1. Make an API key#
A free account is enough, with no card. Its first 50 pages a month print without the mark; after that each page carries a small ReflowPDF mark and nothing else changes (X-ReflowPDF-Mark: free-allowance-used). Pro and Max print every page without it: Pricing and limits.
Sign in at app.reflowpdf.com, open the account menu and choose API keys → New key. The key (rpdf_…) is shown once: keep it in your server's environment, never in a browser or an app you ship.
export REFLOWPDF_API_KEY="rpdf_…"2. Install an SDK (or use curl)#
npm install @reflowpdf/sdkpip install reflowpdf3. Print#
curl https://api.reflowpdf.com/v1/pdf \
-H "Authorization: Bearer $REFLOWPDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello, PDF</h1><p>Printed by ReflowPDF.</p>"}' \
-o hello.pdfimport { ReflowPDF } from '@reflowpdf/sdk'
import { writeFile } from 'node:fs/promises'
const reflow = new ReflowPDF() // reads REFLOWPDF_API_KEY
const pdf = await reflow.pdf.create({
html: '<h1>Hello, PDF</h1><p>Printed by ReflowPDF.</p>',
})
await writeFile('hello.pdf', pdf.bytes)
console.log(pdf.pages, 'page(s)')from reflowpdf import ReflowPDF
client = ReflowPDF() # reads REFLOWPDF_API_KEY
pdf = client.pdf.create(html="<h1>Hello, PDF</h1><p>Printed by ReflowPDF.</p>")
with open("hello.pdf", "wb") as f:
f.write(pdf.content)
print(pdf.pages, "page(s)")Fill a ready template the same way, here the gallery's invoice:
# The template's own sample data is the shape it reads: take it, change what is yours (jq), print.
curl -s https://api.reflowpdf.com/v1/templates/invoice -H "Authorization: Bearer $REFLOWPDF_API_KEY" \
| jq '{data: (.sample_data | .invoice.number = "INV-1042" | .buyer.name = "Globex Corporation")}' \
| curl https://api.reflowpdf.com/v1/templates/invoice/pdf \
-H "Authorization: Bearer $REFLOWPDF_API_KEY" \
-H "Content-Type: application/json" \
-d @- -o INV-1042.pdf// The template's own sample data is the shape it reads: start from it, change what is yours.
const { sample_data } = await reflow.templates.get('invoice')
const pdf = await reflow.templates.pdf('invoice', {
data: { ...sample_data, invoice: { ...sample_data.invoice, number: 'INV-1042' }, buyer: { ...sample_data.buyer, name: 'Globex Corporation' } },
})
await writeFile(pdf.filename, pdf.bytes)# The template's own sample data is the shape it reads: start from it, change what is yours.
sample = client.templates.get("invoice").sample_data
data = {**sample, "invoice": {**sample["invoice"], "number": "INV-1042"}, "buyer": {**sample["buyer"], "name": "Globex Corporation"}}
pdf = client.templates.pdf("invoice", data=data)
pdf.save() # Invoice INV-1042.pdf (the template's <title>)Next#
- Templates: the gallery, your own, and the shape of their data.
- HTML to PDF: paper, headers and footers, PDF/UA.
- Jobs and webhooks: print in the background.
- Errors: every code and what to do.