Back to Blog
Guide March 18, 2026 · 6 min read

Generate PDFs from JavaScript in 2 Lines (No Puppeteer, No Headless Browser)

Puppeteer is a browser automation library. PDFs are a side effect. You're paying the full cost of browser installation, process management, and memory overhead for something that should be simple. There's a better way.

The Puppeteer PDF Problem

Here's what PDF generation looks like with Puppeteer:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: 'new',
    args: ['--no-sandbox']
  });

  const page = await browser.newPage();
  await page.setContent(htmlContent);

  // Wait for assets to load
  await page.waitForNavigation({ waitUntil: 'networkidle2' });

  await page.pdf({
    path: 'invoice.pdf',
    format: 'A4',
    margin: { top: '20px', right: '20px', bottom: '20px', left: '20px' }
  });

  await browser.close();
})();

That's 15 lines for one PDF. And that doesn't include error handling for Chromium crashes, retry logic for timeouts, scaling to multiple concurrent PDFs, or memory leak prevention.

The PageBolt Alternative

Here's the same task:

const response = await fetch('https://pagebolt.dev/api/v1/pdf', {
  method: 'POST',
  headers: { 'x-api-key': YOUR_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ html: htmlContent })
});

const buffer = await response.arrayBuffer();
fs.writeFileSync('invoice.pdf', Buffer.from(buffer));

No browser. No installation. No maintenance.

Replace Puppeteer PDF generation in 5 minutes

100 PDFs free, no credit card required.

Start Free at pagebolt.dev/pricing

What Gets Baked In

PuppeteerPageBolt
Code lines15+2
Setup time30 minutes1 minute
Chrome install150MB+None
Server overhead512MB RAM minimumNone
ScalingManual (process management)Automatic
Reliability~92% (crashes, timeouts)99.9%
Cost$0 + $150–300/mo servers$9–29/mo

Real-World Scenarios

Scenario 1: Generate 1,000 Invoices/Month

Puppeteer: Spawn 5 concurrent browser processes (300MB+ each), handle crashes and retries, monitor CPU/memory. Server: t3.xlarge ($112/mo). Dev time: 40+ hours. Total: $112/mo + your time.

PageBolt: Loop 1,000 times, call API. Built-in queuing and retries. No process management. Cost: $29/month (Starter plan). Dev time: 2 hours.

Scenario 2: PDF Generation in AWS Lambda

Puppeteer: Lambda has no Chrome installed. Use Lambda Layer + bundled Chromium (+300MB to deployment). Requires 512MB+ memory. Cold start: 15–30 seconds. Timeouts: common.

PageBolt: Call API from Lambda. 128MB memory is plenty. Instant execution. 99.9% success rate. $9–29/month.

Scenario 3: Stripe Invoice PDFs

Generate a PDF every time a customer is charged.

// Stripe webhook → PageBolt API → PDF → email attachment
// 5 lines of code, $9/mo, no server overhead
const response = await fetch('https://pagebolt.dev/api/v1/pdf', {
  method: 'POST',
  headers: { 'x-api-key': YOUR_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ html: invoiceHtml, format: 'A4' })
});

Pricing Breakdown

PlanPDFs/MonthCostPer PDF
Puppeteer (self-hosted)Unlimited$150–300/moVariable
PageBolt Free100/mo$0Free
PageBolt Hobby500/mo$9$0.018
PageBolt Starter5,000/mo$29$0.006
PageBolt Pro50,000/mo$99$0.002

At 1,000 PDFs/month: Puppeteer costs $150–300/mo + dev time. PageBolt costs $29/mo, zero maintenance. You save $120–270/month by switching.

How to Switch from Puppeteer

  1. Get PageBolt API key — pagebolt.dev/pricing
  2. Replace Puppeteer code — 5-minute refactor
  3. Run your tests — everything works the same
  4. Delete Puppeteer — npm uninstall puppeteer

When to Keep Puppeteer

  • You need JavaScript execution inside the PDF (dynamic calculations, form validation)
  • Pixel-perfect rendering of complex JavaScript animations
  • You're already running Puppeteer for other tasks and want to minimize dependencies

For everything else — invoices, reports, receipts, contracts — a managed API is the pragmatic choice.

Frequently Asked Questions

Can PageBolt generate PDFs from HTML templates?+

Yes. Pass your HTML string directly in the html parameter. PageBolt renders it in a real Chromium browser, so all your CSS, custom fonts, and inline styles work exactly as they would in a browser. You can also pass a url parameter to render a live URL as a PDF.

Does PageBolt support custom page sizes and margins?+

Yes. Use format (A4, Letter, Legal, etc.), width/height for custom dimensions, and margin for top/right/bottom/left spacing. All standard PDF parameters are supported. See the full reference at pagebolt.dev/docs#post-pdf.

How does pricing compare at scale?+

At 500 PDFs/month: PageBolt Hobby is $9/mo. At 5,000/month: Starter is $29/mo. Compare to self-hosted Puppeteer: a reliable server for concurrent PDF generation costs $150–300/mo plus engineering time for maintenance. PageBolt wins on cost at almost every scale below 100,000 PDFs/month.

Generate PDFs without the browser overhead

Start free — 100 PDFs/month, no credit card.

Start Free at pagebolt.dev/pricing