Custom Page To PDF
Overview
The Custom PageToPDF is a Mendix Web custom widget that exports page content to a PDF file using html2canvas and jsPDF. The widget is designed to handle large pages safely, avoid jsPDF size limits, and provide precise page control by allowing developers to define exact page boundaries in the UI.
Documentation
Overview
PageToPDF is a Mendix Web custom widget that exports page content to a PDF file using html2canvas and jsPDF. The widget is designed to handle large pages safely, avoid jsPDF size limits, and provide precise page control by allowing developers to define exact page boundaries in the UI.
This widget is ideal when you need: - Predictable pagination (e.g., 3 tables per PDF page) - No broken tables or text - Client-side PDF generation (no server dependency)
Key Features
- One UI container = one PDF page
- Supports very large pages (avoids jsPDF 14,400 unit limit)
- Works with Mendix-generated HTML (mx-* classes)
- Supports DataGrid and ListView rendering completion
- Portrait and Landscape orientation
- Custom file name support
How Pagination Works
The widget does not auto-split content.
Instead, pagination is controlled in the UI using wrapper containers:
- Each PDF page must be wrapped in a container whose class starts with:
- pagestart1, pagestart2, pagestart3, …
- All pagestartX containers must be inside one parent container with class:
- pdfpage
Each pagestartX container is captured separately and added as one PDF page.
Required Page Structure (Mendix)
Parent Container
- Add a container (Layout Grid / Container)
- Set Class to:pdfpage[Can be any name]
Page Containers
Inside the parent container, create one container per PDF page:
Important Rules
- pagestartX numbers define page order
- One pagestartX = exactly one PDF page
- Do not nest pagestartX containers
- Ensure containers are visible at runtime
Common Errors & Fixes
“No pagestartX containers found”
Cause: - Class not rendered in DOM - Container is conditionally hidden - Missing pdfpage parent
Fix: - Verify rendered HTML in browser DevTools - Ensure class is applied to the actual container
Example Use Case
Requirement: Export 10 tables, 3 tables per page
Solution: - Page 1 → pagestart1 → Tables 1–3 - Page 2 → pagestart2 → Tables 4–6 - Page 3 → pagestart3 → Tables 7–9 - Page 4 → pagestart4 → Table 10
When NOT to Use This Widget
Do not use this widget if you need: - Editable PDFs - Searchable/selectable text - Legal or print-grade documents
Use server-side PDF generation instead (Java / iText / Document generation).
Releases
This widget is updated to reduce the pdf size and compress the size so that download will complete in short and also various compression applied.
PageToPDF is a Mendix Web custom widget that exports page content to a PDF file using html2canvas and jsPDF. The widget is designed to handle large pages safely, avoid jsPDF size limits, and provide precise page control by allowing developers to define exact page boundaries in the UI.