- Invoices & Receipts: Generate professional invoices with automated delivery
- Reports & Analytics: Multi-page reports with charts and tables
- Certificates: Dynamic certificates with custom data
- Documentation: Export documentation as PDF
Quick Start
Generate PDF from Inline HTML
Invoice with R2 Storage
HTML Sources
Inline HTML
Best for simple documents:From HTML Member
Use HTML member output for complex templates:From Template
Load and render templates directly:Page Configuration
Page Sizes
- A4: 210 � 297mm (default)
- A3: 297 � 420mm
- A5: 148 � 210mm
- Letter: 8.5 � 11 inches
- Legal: 8.5 � 14 inches
- Tabloid: 11 � 17 inches
Custom Margins
Headers and Footers
With Page Numbers
{{pageNumber}}- Current page number{{totalPages}}- Total page count
R2 Storage
Basic Storage
static/generated-{timestamp}-{random}.pdf
Public URLs
Delivery Modes
Display in Browser (Inline)
Content-Disposition: inline; filename="report.pdf"
User sees PDF in browser viewer.
Force Download (Attachment)
Content-Disposition: attachment; filename="invoice-123.pdf"
Browser downloads the PDF immediately.
PDF Metadata
Complete Examples
Professional Invoice
Multi-Page Report from HTML Member
Configuration Reference
Member Config
Output
Best Practices
HTML Design
- Use inline styles - External stylesheets may not load
- Test in browser first - Preview HTML before PDF generation
- Avoid JavaScript - PDFs are static
- Use web-safe fonts - Or embed fonts
- Page breaks: Use
page-break-before: alwaysfor new pages
Performance
- Cache HTML templates in KV
- Reuse HTML member for multiple PDFs
- Optimize images - Compress before embedding
- Minimize HTML for faster generation
Storage
- Organize R2 keys - Use folders:
static/invoices/,static/reports/ - Include identifiers in filenames -
invoice-{number}.pdf - Set public URLs only when needed
- Clean up old PDFs periodically
Troubleshooting
PDF Generation Fails
Check:- HTML is well-formed (closing tags, valid structure)
- Images use absolute URLs or data URIs
- No external resources that can’t load
- Page config is valid (margins, scale)
Styles Not Rendering
Solutions:- Use inline
<style>tags, not external CSS - Check CSS syntax
- Enable
printBackground: truefor backgrounds - Use
!importantfor critical styles
R2 Storage Errors
Check:- R2 binding exists in
wrangler.toml - Binding name matches config (default: ASSETS)
- R2 key doesn’t contain
..or start with/ - Bucket has sufficient storage
File Too Large
Solutions:- Compress images before embedding
- Reduce HTML complexity
- Split into multiple PDFs
- Optimize CSS (remove unused rules)
Next Steps
- HTML Member - Create HTML templates for PDFs
- Email Member - Attach PDFs to emails
- R2 Storage - Configure R2 buckets

