DEV Community

Cover image for I got tired of setting up Puppeteer every project, so I built a PDF API
Sanidhya
Sanidhya

Posted on

I got tired of setting up Puppeteer every project, so I built a PDF API

Every SaaS project I've worked on eventually needed PDFs.

Invoices. Reports. Certificates. Contracts.

And every single time, the process looked like this:

  1. Install Puppeteer
  2. Spend 2 hours configuring headless Chrome
  3. Fight with CSS that renders differently in headless mode
  4. Deploy and discover it doesn't work on the server
  5. Find @sparticuz/chromium, configure outputFileTracingIncludes
  6. Finally get it working — until the next deployment breaks it again

After going through this cycle on three different projects, I decided to build something better.

Introducing PDFGen AI

PDFGen AI is a REST API that turns your data into
beautiful PDFs with a single API call — in under 3 seconds.

No Puppeteer. No headless Chrome. No server configuration nightmares.

  curl -X POST https://pdfgen-api.vercel.app/api/generate \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "template": "invoice",
      "data": {
        "company": "Acme Corp",
        "client": "John Doe",
        "items": [
          { "name": "Web Development", "price": 1500 }
        ]
      }
    }'
Enter fullscreen mode Exit fullscreen mode

That's it. You get a PDF back. Done.

How it works

PDFGen AI has three core endpoints:

  1. /api/generate — Instant PDF from a template

Pick one of 5 built-in professional templates (invoice, report, contract,
certificate, letter), pass your data as JSON, get a PDF URL back.

  1. /api/ai/template — Generate a custom template with AI

Describe what you want in plain English:

{
"description": "A modern SaaS invoice with a dark header,
itemized table, and payment terms section"
}

The API uses Claude (via Amazon Bedrock) to generate an HTML/CSS template
that matches your description. Save it, reuse it forever.

  1. /api/ai/fill — AI-powered data mapping

Got messy or inconsistently structured data? Send it raw and the AI
figures out how to map it to your template. No manual field mapping needed.

Why I built this on Bedrock + Vercel

I wanted reliability without the ops burden.

  • Amazon Bedrock for AI — no model hosting, pay per token, multiple models available
  • Vercel for deployment — zero-config, scales automatically, global edge network
  • Supabase for storage — PDF URLs are stored and retrievable
  • Chromium (via @sparticuz/chromium) runs serverlessly — the hard part is already configured for you

The whole thing runs serverlessly. No VMs to manage. No Docker containers.
No "it works on my machine" moments.

Pricing

  • Free: 50 PDFs/month — enough to evaluate and build your integration
  • Pro: $49/month — unlimited PDFs, priority support
  • Business: $99/month — custom templates, SLA, dedicated support

No credit card required for the free tier.

What I've learned building this

A few things surprised me along the way:

Chromium on serverless is harder than it looks. Getting
@sparticuz/chromium to work on Vercel requires specific configuration
in next.config.js (outputFileTracingIncludes) and using
headless: "shell" instead of headless: true. Spent a full day on this.

AI data mapping is genuinely useful. The /api/ai/fill endpoint came
from a real pain point — different clients send invoice data in wildly
different formats. Instead of writing custom parsers, you just let the AI
figure it out.

Developers want simplicity above all else. The most common feedback
I've gotten: "I just want to POST some data and get a PDF." That's the
whole product.

Try it

The API is live at https://pdfgen-api.vercel.app.

Free tier, no credit card, full API docs included.

I'd love to know: what's the most painful PDF use case you've dealt with?
Drop it in the comments — I'm actively building new templates based on
what people actually need.


Built by a solo developer in India. Feedback welcome — brutal honesty
appreciated.


Top comments (0)