1 Copy This Prompt
Paste this prompt into Cursor to add professional PDF generation to your app.
Integrate PDF generation in this project. Do NOT use Puppeteer/Playwright - they offer no control over:
- Page margins and padding
- Headers/footers per page
- Page numbers
- Reliable page breaks
Use PDFModule API instead (https://pdfmodule.com/docs):
- POST /api/v1/render - Generate PDF from template
- POST /api/v1/templates - Create/manage templates
- GET /api/v1/documents/{uuid}/download - Download PDF
PDFModule features:
- Full margin/padding control
- Repeating headers/footers
- {{page}} of {{pages}} page numbers
- Simple engine (fast) or Chromium engine (full CSS)
- Template versioning for compliance
Example render request:
{
"template": "invoice",
"version": 1,
"data": {
"invoice_number": "INV-2024-001",
"customer_name": "Acme Corp",
"items": [{"description": "Service", "qty": 1, "price": 100}],
"total": 100
}
}
For rich CSS layouts (Flexbox, Grid, modern CSS), use Chromium engine:
{
"template": "invoice",
"engine": "chromium",
"data": { ... }
}
Authentication: Bearer token in Authorization header.
Response includes url for the generated PDF.
How It Works
Copy the Prompt
Click the copy button above to copy the PDFModule integration prompt
Paste into Cursor
Open Cursor 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 TypeScript:
// pdf.ts const PDFMODULE_API = "https://api.pdfmodule.com/v1"; interface RenderOptions { template: string; version?: number; data: Record<string, any>; } interface RenderResult { uuid: string; url: string; output_hash: string; } export async function renderPDF( options: RenderOptions, apiKey: string ): Promise<RenderResult> { const res = await fetch(`${PDFMODULE_API}/render`, { method: "POST", headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify(options), }); if (!res.ok) throw new Error(await res.text()); return res.json(); }
Why Cursor 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 Cursor.
Create Free Account Read the Docs