
I Built a PDF Generation API — Here's the Tech Stack and What I Learned
I recently shipped RenderPDFs — a simple API that converts HTML or URLs to PDFs. Here's the full breakdown: stack, architecture decisions, and the painful lessons along the way. The Stack Fastify — blazing fast Node.js framework, perfect for API services Puppeteer — headless Chrome for pixel-perfect PDF rendering PostgreSQL — API keys, users, usage tracking Cloudflare R2 — PDF file storage with presigned URLs (S3-compatible, cheaper than AWS) Next.js 15 — frontend dashboard and docs Railway — deployment with zero DevOps headaches How It Works The core flow is dead simple: const browser = await puppeteer . launch (); const page = await browser . newPage (); await page . setContent ( html , { waitUntil : " networkidle0 " }); const pdf = await page . pdf ({ format : " A4 " , printBackground : true }); await browser . close (); Send HTML, get a PDF. That's it. For URL-to-PDF I added SSRF protection to block requests to internal IPs — important if you're exposing this publicly. The Auth Flo
Continue reading on Dev.to Tutorial
Opens in a new tab



