pdf_forge
PDF Forge lets you export Drupal content to PDF with zero external binaries. It converts render arrays into polished PDFs using Dompdf, with optional headers/footers, page sizes, orientations, and pagination. New to Drupal? Enable the module, visit the demo page, and see your first PDF in seconds.
Features
- Render arrays → PDF: Generate PDFs directly from Drupal render arrays (pure PHP via Dompdf).
- Headers & footers: Inject custom HTML headers/footers with explicit height controls.
- Page setup: Choose page size (A4, Letter, etc.) and orientation (portrait/landscape).
- Styling: Add inline CSS and optional external CSS (with host allowlist).
- Pagination: Automatic page numbers with configurable coordinates.
- Demo hub: Built-in basic & advanced demos to sanity-check your setup.
- Service API: Clean interface (
PdfForgeInterface) for developers to integrate anywhere.
When to use: Invoices, receipts, order summaries, certificates, brochures, reports, or any printable view of site content.
Post-Installation
- Enable PDF Forge.
- Visit
/admin/config/development/pdf-forge/demoto try the Basic and Advanced demos. - Configure defaults at
/admin/config/development/pdf-forge/settings(font, page size, orientation, remote asset allowlist). - Developers: inject
pdf_forge.forge(type-hintPdfForgeInterface) and callrender($build, $options).
Tip: The advanced demo includes a header logo bundled in the module so it works out of the box.
Additional Requirements
- Library:
dompdf/dompdf(installed via Composer). - PHP: 8.1+ (recommended).
- No external binaries (e.g., wkhtmltopdf) are required.
Recommended modules/libraries
- Composer for managing
dompdf/dompdfand any CSS dependencies. - Devel (optional) to quickly build/test render arrays during development.
Similar projects
Other solutions include PDF/print modules that rely on different engines (e.g., wkhtmltopdf) or focus on printing node content. PDF Forge is distinguished by:
- Pure-PHP Dompdf engine (simple hosting, no extra binaries).
- Render-array centric API (works with any buildable structure, not just nodes).
- Explicit header/footer sizing and pagination controls.
- Built-in demo hub for instant validation.
Supporting this Module
If this module saves you time or budget, you can support development here:
- Buy me a coffee
- Sponsor feature requests via GitHub or the issue queue
Community Documentation
Basic documentation is available in the module’s README.md.