Large Documents
Strategies for generating complex, multi-page documents with extensive data and many elements.
What Counts as Large?
A document becomes "large" when it pushes beyond typical use cases:
- More than 10 pages
- Tables with 100+ rows
- More than 20 images
- Data payloads exceeding 500KB
- Many dynamic elements with complex bindings
Page Management
Use the multi-page feature to break long documents into pages. Design each page template separately so the engine can process them efficiently.
- Keep page templates focused — don't overload a single page with dozens of elements
- Use consistent layouts across pages for predictable rendering
- Place repeating headers and footers so they don't need recalculation
Handling Large Tables
Tables with many rows are the most common cause of large documents. Consider these approaches:
- Paginate the data — Split large datasets across multiple pages
- Limit rows per page — Design the table to fit a fixed number of rows, then overflow to a new page
- Summary tables — Show grouped or aggregated data instead of raw rows
- Appendix pattern — Show a summary on page one, detailed data on following pages
Row Limits
For best performance, keep tables under 50 rows per page. If you need more, split across pages and include "Continued on next page" markers.Image-Heavy Documents
- Pre-optimize all images before using them in templates
- Use JPEG format for photographs (smaller file size)
- Use PNG only when transparency is required
- Host images on a CDN for fast fetching
- Avoid embedding base64 images in the data payload
Data Payload Best Practices
- Only include data fields that the template references
- Pre-format values (dates, currency) on the client side
- Remove null or empty fields from the payload
- Flatten deeply nested structures when possible
Timeout Handling
Large documents may take longer to generate. Handle this gracefully:
- Use async generation with webhooks for documents that may take more than a few seconds
- Set appropriate timeout values in your HTTP client
- Show a progress indicator or "generating..." state in your UI
- Implement retry logic with exponential backoff
Request Timeout
The API has a maximum request timeout. For very large documents, always use webhooks to receive the completed PDF asynchronously.Splitting Into Multiple PDFs
Sometimes it's better to generate multiple smaller PDFs instead of one large one:
- Generate individual invoices instead of one combined PDF
- Split a report into chapters, each as a separate PDF
- Use a cover page PDF + content PDF + appendix PDF
Next Steps
- Performance Optimization — General speed tips
- Batch Processing — Generate many documents efficiently
- Multi-Page Templates — Design multi-page layouts