Doc API
Puppeteer Alternative

Generate PDFs without managing Chromium

Puppeteer is a great tool — but for PDF generation it brings 150MB of Chromium, 3–5 second cold starts, Lambda layer headaches, and memory management bugs. DocAPI does the same job in 3 lines with a 10ms cold start and zero binaries.

Free tier: 100 PDFs/month. No credit card required.

The real cost of running Puppeteer in production

Puppeteer works fine on your laptop. It's the serverless and container deployment where things get painful.

150MB+ binary on every deploy

Puppeteer downloads a full Chromium binary on npm install. That bloats your Lambda package, Docker image, and CI cache dramatically.

3–5 second cold starts

Launching a headless browser takes seconds. In serverless environments where cold starts are common, this is a real user-facing latency problem.

Lambda layer complexity

Running Puppeteer on AWS Lambda requires a custom layer with Chromium binaries compiled for the right Amazon Linux version — and keeping it updated.

Memory spikes under load

Each concurrent PDF request spins up a browser page. Under load, memory usage spikes unpredictably and OOM errors crash your function.

Browser leak bugs

If your PDF generation throws before browser.close(), the browser process leaks. These are subtle bugs that only appear in production under load.

Sandbox flags for containers

Docker and Kubernetes require --no-sandbox and other Chromium flags to run. Easy to forget, painful to debug when it breaks in a new environment.

Before and after

Same output. Dramatically less code and zero infrastructure overhead.

Before — Puppeteer
generate-pdf-puppeteer.ts
// Before: Puppeteer — verbose, heavy, fragile in serverless
import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
  // Required flags for Lambda/Docker
  args: ["--no-sandbox", "--disable-setuid-sandbox",
         "--disable-dev-shm-usage", "--single-process"],
  executablePath: process.env.CHROMIUM_PATH || undefined,
});

const page = await browser.newPage();
await page.setContent(html, { waitUntil: "networkidle0" });
const pdf = await page.pdf({
  format: "A4",
  printBackground: true,
  margin: { top: "40px", right: "40px", bottom: "40px", left: "40px" },
});
await browser.close();

// + 150MB Chromium download on npm install
// + Custom Lambda layer or Docker layer
// + 3–5s cold starts
// + Memory spikes on concurrent requests
// + Memory leaks if browser.close() throws
After — DocAPI
generate-pdf-docapi.ts
// After: DocAPI — 3 lines, works everywhere
import { DocAPI } from "@docapi/sdk";

const client = new DocAPI(process.env.DOCAPI_KEY);
const pdf = await client.pdf(html, { format: "A4" });
// done — no browser, no memory management, no binary layers
Serverless-native

Works anywhere — no layers, no config

The same 3-line API call works identically on Lambda, Vercel, Cloudflare, and your local machine.

AWS Lambda

No custom runtime, no Chromium layer

// AWS Lambda handler — just works, no layer needed
import { DocAPI } from "@docapi/sdk";

const client = new DocAPI(process.env.DOCAPI_KEY!);

export const handler = async (event: AWSLambda.APIGatewayEvent) => {
  const { html } = JSON.parse(event.body ?? "{}");
  const pdf = await client.pdf(html, { format: "A4" });

  return {
    statusCode: 200,
    headers: { "Content-Type": "application/pdf" },
    body: pdf.toString("base64"),
    isBase64Encoded: true,
  };
};

Vercel / Next.js

Works in Node.js runtime, not edge-only

// Vercel serverless function — no edge runtime needed
import { DocAPI } from "@docapi/sdk";

const client = new DocAPI(process.env.DOCAPI_KEY!);

export async function GET(req: Request) {
  const url = new URL(req.url);
  const id = url.searchParams.get("id")!;

  const html = await buildReportHtml(id);
  const pdf = await client.pdf(html, { format: "A4" });

  return new Response(pdf, {
    headers: { "Content-Type": "application/pdf" },
  });
}

Same PDF quality. None of the browser overhead.

DocAPI uses a managed Chromium fleet on the server side — so you get identical, pixel-perfect PDF output without any of the infrastructure burden. We handle browser pooling, memory management, scaling, and updates.

  • ~10ms cold start vs 3–5s for Puppeteer (no browser launch)
  • Zero deployment footprint — no binary, no layer, no container change
  • Concurrent requests handled by our fleet — no OOM on your function
  • No browser.close() leak bugs — stateless HTTP call
  • Same Chromium rendering engine — identical PDF output
  • Full CSS, custom fonts, print media queries all work
  • Margin, header, footer, and page break control

Cold start

Puppeteer

3–5 seconds

DocAPI

~10ms

Deployment size

Puppeteer

+150MB Chromium

DocAPI

+0 bytes

Lambda setup

Puppeteer

Custom layer required

DocAPI

Works out of the box

Memory per request

Puppeteer

~200MB spike

DocAPI

Negligible (HTTP call)

Concurrent PDFs

Puppeteer

One browser per worker

DocAPI

Unlimited (our fleet)

Where DocAPI replaces Puppeteer

Invoice and receipt PDFs

Generate customer-facing PDF invoices and receipts on demand from your Node.js or Python backend. No browser to launch.

Serverless document generation

Lambda or Vercel functions that generate PDFs without needing a custom Chromium layer or docker image. Instant cold starts.

Scheduled report exports

Nightly cron jobs that generate HTML reports and convert to PDF. No long-running browser process to manage on a cron worker.

SaaS PDF export features

Add 'Export as PDF' to any page in your SaaS. One API call per export — no per-tenant browser instance needed.

Contract generation

Legal document generation from HTML templates. Predictable output, fast generation, no browser pool to scale.

CI/CD PDF artifacts

Generate PDF documentation, changelogs, or test reports as part of your build pipeline without spinning up a Chromium container.

vs. Puppeteer, html-pdf, and Playwright

Every browser-based PDF tool has the same fundamental tradeoff: you must ship and manage a browser binary.

FeatureDocAPIPuppeteerhtml-pdfPlaywright
No binary download150MB Chromiumwkhtmltopdf300MB+ browsers
Cold start time~10ms3–5s~500ms3–5s
Works in LambdaCustom layerCustom layer
No memory leaksManual close()Manual close()Manual close()
Full CSS supportPartial
Serverless friendlyComplexComplex
Free tier100/moSelf-hostedSelf-hostedSelf-hosted

Ready to remove Puppeteer from your project?

Free tier includes 100 PDFs per month. Replace Puppeteer in your project today — no credit card, no Chromium, no infrastructure changes.

Puppeteer Alternative — Generate PDFs Without Chromium | Doc API