> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getdeckle.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Deckle vs Puppeteer

> Compare Deckle's managed PDF API against self-hosted Puppeteer/Playwright

# Deckle vs Puppeteer / Playwright

Puppeteer (and Playwright) are the most common approaches to PDF generation — run headless Chrome, navigate to a page, and call `page.pdf()`. Deckle uses the same underlying technology but wraps it in a managed API so you don't have to operate browser infrastructure.

## Feature Comparison

| Feature                 | Deckle                            | Puppeteer (Self-Hosted)            |
| ----------------------- | --------------------------------- | ---------------------------------- |
| **Setup time**          | 5 minutes                         | 2-5 days                           |
| **Infrastructure**      | Managed (zero ops)                | You manage Chrome, Docker, scaling |
| **SDKs**                | TypeScript, Python, Go, Ruby      | JavaScript only                    |
| **Memory management**   | Handled (browser pool, recycling) | Manual (memory leaks are common)   |
| **Page breaks**         | Smart orphan/widow protection     | Manual CSS rules                   |
| **Headers/Footers**     | Built-in with `{{pageNumber}}`    | Manual HTML injection              |
| **Templates**           | Visual editor + template engine   | Build your own                     |
| **Batch generation**    | API endpoint (1-10K PDFs)         | Build queue yourself (BullMQ etc.) |
| **QR codes / Barcodes** | Built-in                          | Add a library (qrcode, bwip-js)    |
| **Custom fonts**        | Upload via API                    | Install in Docker image            |
| **React-to-PDF**        | Native support                    | `renderToStaticMarkup` + custom    |
| **Cost**                | Free tier: 1,000/mo, from \$29/mo | Server costs (\$50-200/mo+)        |

## Code Comparison

### Puppeteer (Self-Hosted)

```javascript theme={null}
const puppeteer = require('puppeteer');

// Launch browser (watch for memory leaks)
const browser = await puppeteer.launch({
  headless: 'new',
  args: ['--no-sandbox', '--disable-setuid-sandbox'],
});

const page = await browser.newPage();
await page.setContent(htmlContent, { waitUntil: 'networkidle0' });

const pdf = await page.pdf({
  format: 'A4',
  margin: { top: '1in', bottom: '1in', left: '0.75in', right: '0.75in' },
  displayHeaderFooter: true,
  headerTemplate: '<div style="font-size:10px">My Company</div>',
  footerTemplate: '<div style="font-size:10px; text-align:center; width:100%">Page <span class="pageNumber"></span> of <span class="totalPages"></span></div>',
  printBackground: true,
});

// Upload to S3 yourself
await s3.putObject({ Bucket: 'my-pdfs', Key: 'output.pdf', Body: pdf });

// Don't forget to close!
await page.close();
// And recycle browsers periodically to prevent memory leaks...
```

### Deckle

```typescript theme={null}
import { Deckle } from '@getdeckle/sdk';
const df = new Deckle('dk_live_...');

const pdf = await df.generate({
  html: htmlContent,
  options: {
    format: 'A4',
    margin: { top: '1in', bottom: '1in', left: '0.75in', right: '0.75in' },
    header: '<div style="font-size:10px">My Company</div>',
    footer: '<div style="font-size:10px; text-align:center">Page {{pageNumber}} of {{totalPages}}</div>',
  },
});

console.log(pdf.url); // Hosted, CDN-delivered PDF
```

## When to Choose Puppeteer

* You need full browser automation (screenshots, scraping, testing)
* You have strict data residency requirements and can't use cloud APIs
* You're already operating browser infrastructure at scale

## When to Choose Deckle

* You want to generate PDFs without managing infrastructure
* You need batch generation, templates, or React-to-PDF support
* You want to go from zero to working PDFs in minutes, not days
* You need multi-language SDK support (Python, Go, Ruby)
