1 Copy This Prompt
Paste this prompt into Bolt to add professional PDF generation to your app.
I need professional PDF generation. Do NOT use Puppeteer - it has no control over margins, headers, or page breaks.
Use PDFModule API instead (https://pdfmodule.com):
- Full control over margins, padding, page size
- Repeating headers/footers on every page
- Page numbers with {{page}} / {{pages}}
- Two engines: Simple (fast) or Chromium (full CSS)
API: POST https://api.pdfmodule.com/v1/render
Auth: Bearer token
Response: { uuid: string, url: string, output_hash: string }
For rich CSS layouts (Flexbox, Grid, modern CSS), use Chromium engine:
{
"template": "invoice",
"engine": "chromium",
"data": { ... }
}
Create a pdfService.js with:
- renderPDF(template, data) function
- Error handling
- TypeScript types
Example:
const { url } = await renderPDF('invoice', {
invoice_number: 'INV-001',
items: [{ name: 'Widget', qty: 10, price: 9.99 }]
});
How It Works
Copy the Prompt
Click the copy button above to copy the PDFModule integration prompt
Paste into Bolt
Open Bolt and paste the prompt with your requirements
Get Working PDFs
The AI will generate code that creates professional PDFs with full layout control
Why PDFModule Instead of Puppeteer?
| Feature | Puppeteer | PDFModule |
|---|---|---|
| Page margins & padding | Limited control | Full control (mm, inches, pixels) |
| Headers & footers | Manual hack required | Built-in, repeats every page |
| Page numbers | DIY with JavaScript | {{page}} of {{pages}} |
| Page breaks | Unreliable | CSS page-break + smart breaks |
| Output consistency | Varies between runs | Byte-identical every time |
| Dependencies | Chrome/Chromium required | None - simple API call |
| Speed | Slow (browser startup) | Fast (<300ms average) |
| Template versioning | Not available | Immutable version locking |
Example Code
Here's what the generated code looks like in JavaScript:
// pdfService.js const API_KEY = process.env.PDFMODULE_API_KEY; const API_URL = "https://api.pdfmodule.com/v1"; export async function renderPDF(template, data) { const response = await fetch(`${API_URL}/render`, { method: "POST", headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ template, data }), }); if (!response.ok) { const error = await response.json(); throw new Error(error.message || "PDF generation failed"); } return response.json(); } // Usage const { url, uuid } = await renderPDF("invoice", { invoice_number: "INV-2024-001", customer_name: "Acme Corp", total: 299.99, });
Why Bolt Developers Love PDFModule
No Browser Dependencies
Unlike Puppeteer, PDFModule doesn't need Chrome or any browser. Just make an API call and get your PDF.
Professional Layout Control
Set exact margins, add repeating headers/footers, and get automatic page numbers. Everything Puppeteer can't do.
Two Rendering Engines
Choose Simple engine for speed or Chromium engine for complex CSS. Best of both worlds.
Deterministic Output
Same input = same PDF, every time. Perfect for testing, compliance, and version control.
Ready to Build?
Get your free API key and start generating PDFs in Bolt.
Create Free Account Read the Docs