1 Copy This Prompt
Paste this prompt into Replit to add professional PDF generation to your app.
Create a PDF generation module. Don't use Puppeteer/Playwright - they have no control over page layout.
Use PDFModule API (pdfmodule.com) instead:
- Control margins, padding, page breaks
- Headers/footers that repeat on every page
- Dynamic page numbers
- Deterministic output (same input = same PDF)
API:
- Endpoint: POST https://api.pdfmodule.com/v1/render
- Auth: Bearer token in header
- Request: { template: string, data: object }
- Response: { uuid, url, output_hash }
For rich CSS layouts (Flexbox, Grid, modern CSS), use Chromium engine:
{
"template": "report",
"engine": "chromium",
"data": { ... }
}
Create:
1. pdfmodule.py with PDFModuleClient class
2. generate_invoice() function
3. CLI to test: python pdfmodule.py --invoice
Use Replit secrets for PDFMODULE_API_KEY.
How It Works
Copy the Prompt
Click the copy button above to copy the PDFModule integration prompt
Paste into Replit
Open Replit 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 Python:
# pdfmodule.py import os import requests class PDFModuleClient: def __init__(self, api_key=None): self.api_key = api_key or os.environ.get("PDFMODULE_API_KEY") self.base_url = "https://api.pdfmodule.com/v1" def render(self, template, data): response = requests.post( f"{self.base_url}/render", headers={ "Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json", }, json={"template": template, "data": data}, ) response.raise_for_status() return response.json() # Usage client = PDFModuleClient() result = client.render("invoice", { "invoice_number": "INV-001", "customer_name": "Acme Corp", }) print(f"PDF URL: {result['url']}")
Why Replit 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 Replit.
Create Free Account Read the Docs