Generate PDFs programmatically

Stop fighting with wkhtmltopdf. Use our reliable REST API to convert HTML, CSS, and URLs into pixel-perfect PDF documents in seconds.

Processed in memory — we don’t store your documents.

invoice_generator.py
                        
import requests
response = requests.post(
  "https://api.headlesspdf.com/v1/generate-pdf",
  headers={"X-API-Key": "YOUR_KEY"},
  json={
    "url": "https://example.com/invoice/1024",
    "format": "A4"
  }
)
# Save the PDF
with open("invoice.pdf", "wb") as f:
  f.write(response.content)
                        
                    

Lightning Fast

Generate simple documents in under 3s. Our distributed clusters handle high concurrency effortlessly.

Developer Friendly

Simple JSON payload. No complex configurations. Works with Python, Node, PHP, Go, and more.

Secure & Private

We don't store your data. Documents are processed in memory and deleted immediately after delivery.

Integrate in Minutes

Choose your preferred language to see how easy it is.


import requests
response = requests.post(
  "https://api.headlesspdf.com/v1/generate-pdf",
  headers={"X-API-Key": "YOUR_KEY"},
  json={
    "url": "https://example.com/invoice/1024",
    "format": "A4"
  }
)
# Save the PDF
with open("invoice.pdf", "wb") as f:
  f.write(response.content)

    

const response = await fetch("https://api.headlesspdf.com/v1/generate-pdf", {
  method: "POST",
  headers: {
    "X-API-Key": "YOUR_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    url: "https://example.com/invoice/1024",
    format: "A4"
  })
});

const buffer = await response.arrayBuffer();

// Save the PDF (Node.js)
require("fs").writeFileSync("invoice.pdf", Buffer.from(buffer));

    

curl https://api.headlesspdf.com/v1/generate-pdf \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/invoice/1024",
    "format": "A4"
  }' \
  --output invoice.pdf

    

require 'httparty'

response = HTTParty.post(
  "https://api.headlesspdf.com/v1/generate-pdf",
  headers: {
    "X-API-Key" => "YOUR_KEY",
    "Content-Type" => "application/json"
  },
  body: {
    url: "https://example.com/invoice/1024",
    format: "A4"
  }.to_json
)

File.write("invoice.pdf", response.body, mode: "wb")

    

Frequently Asked Questions

Everything you need to know about the product.

We use a highly optimized, headless Chromium instance. This ensures that your PDFs are rendered exactly as modern web browsers see them, supporting the latest CSS3, Flexbox, Grid, and JavaScript features.

Absolutely. You can inject raw CSS directly into the request options for self-contained generation.

Security is our priority. We process your HTML entirely in memory. Once the PDF is generated and returned to your API request, both the source HTML and the resulting PDF are permanently wiped from our servers. We do not store your documents.

Yes! Every new account comes with a free tier that allows you to generate up to 10 documents per month without adding a credit card. It's perfect for development, testing, and small projects.

Ready to start generating?

Sign up and save time, money and energy with HeadlessPDF.

View Pricing Plans