FillPDF
Allows users to populate fillable PDF forms with data from Drupal entities.
fillpdf
Install
composer require 'drupal/fillpdf:^5.2'
composer require 'drupal/fillpdf:^5.1'
Overview
FillPDF is a powerful module that enables you to automatically populate fillable PDF forms with data from your Drupal site. It supports token-based field mapping, allowing you to map PDF form fields to entity data such as nodes, users, webforms, and any other content entities.
The module provides flexible PDF backend options including PDFtk (local installation), FillPDF LocalServer (Docker-based API), and FillPDF Service (remote API). Generated PDFs can be downloaded directly, saved to the filesystem, or redirected to automatically.
Key capabilities include support for images in PDF fields, text transformations/replacements, PDF security settings (encryption and permissions via PDFtk), and the ability to export/import form configurations between sites.
Features
- Populate fillable PDF forms with entity data from nodes, users, webforms, and other content types using token-based field mapping
- Support for multiple PDF processing backends: PDFtk (local), FillPDF LocalServer (Docker), and FillPDF Service (remote API)
- Generate sample PDFs showing field names for easy field identification and mapping
- Store generated PDFs to filesystem (public or private) or send directly to browser for download
- Token support for dynamic filename patterns and destination paths
- Text transformation/replacement rules to modify values before inserting into PDFs
- PDF security features including encryption (128-bit or 40-bit) and user permissions (via PDFtk backend)
- Export and import FillPDF form configurations and field mappings between sites
- Duplicate existing FillPDF form configurations
- Support for image fields in PDF templates
- Integration with Webform module for populating PDFs from form submissions
- Views integration for managing FillPDF forms and fields
- Hooks for altering form behavior and PDF population context
Use Cases
Contract/Agreement Generation
Automatically populate contract PDFs with customer data from nodes or user profiles. Create a FillPDF form from your contract template, map fields to node:title, user:name, etc., and generate personalized contracts via URLs like /fillpdf?fid=1&entity_id=node:42.
Webform Submission to PDF
Convert webform submissions into filled PDF documents. Upload a fillable PDF version of your webform, map fields to webform_submission tokens, and allow users to download their submission as a professional PDF.
Certificate Generation
Generate certificates with user names and dates. Create a certificate template with fillable fields for name, course title, completion date, etc., and map to user and date tokens for automatic generation.
Application Forms Pre-fill
Pre-fill application PDFs with known user data. Map PDF fields to user profile tokens so returning users can download application forms with their information already filled in.
Invoice/Receipt Generation
Create invoices populated with order data from commerce or custom entities. Map product names, quantities, prices, and customer information to generate downloadable invoices.
Multi-Entity Document Merge
Combine data from multiple entities in a single PDF. Use URL parameters like /fillpdf?fid=1&entity_ids[]=node:10&entity_ids[]=user:7 to merge data from different sources.
Tips
- Use the 'Sample PDF' feature to generate a PDF showing all field names - this makes field mapping much easier.
- When creating fillable PDFs, use simple field names without special characters for easier token mapping.
- For security, use the private:// storage scheme for generated PDFs containing sensitive data.
- Export your FillPDF form configurations before making major changes - you can import them back if needed.
- The &download=1 URL parameter forces a download even when the PDF is configured to be saved to disk.
- Use the &flatten=0 parameter to generate editable PDFs that users can continue to fill out.
- Test your PDF population with a default entity before deploying to production.
- For PDFtk backend, use 128-bit encryption and set owner/user passwords for sensitive documents.
- Value transformations are processed in order - place more specific replacements before general ones.
Technical Details
Admin Pages 7
/admin/config/media/fillpdf
Configure the PDF processing backend and storage settings for FillPDF. This is where you select which PDF manipulation tool to use and configure its specific settings.
/admin/structure/fillpdf
Main overview page for managing FillPDF forms. Lists all uploaded PDF templates and provides the interface to upload new templates.
/admin/structure/fillpdf/{fillpdf_form}
Edit a FillPDF form's settings and manage field mappings. Configure how the PDF is populated with entity data.
/admin/structure/fillpdf/{fillpdf_form}/{fillpdf_form_field}
Configure the mapping for a specific PDF form field, including the fill pattern (tokens) and value transformations.
/admin/structure/fillpdf/{fillpdf_form}/export
Export the FillPDF form configuration and field mappings as JSON code for importing on another site.
/admin/structure/fillpdf/{fillpdf_form}/import
Import field mappings from another FillPDF form. Useful for copying configurations between sites.
/admin/structure/fillpdf/{fillpdf_form}/duplicate
Create a copy of an existing FillPDF form including all its field mappings.
Permissions 3
Hooks 2
hook_fillpdf_form_form_pre_form_build_alter
Allows altering a FillPdfFormForm prior to building its edit form. Useful for setting default values or modifying form behavior.
hook_fillpdf_populate_pdf_context_alter
Allows altering the context array during PDF population in HandlePdfController::populatePdf(). Can modify entity IDs, flags, or add additional data.
Troubleshooting 7
Ensure your PDF contains actual fillable form fields (created in Adobe Acrobat or similar). Regular text annotations are not fillable fields. Use the 'Sample PDF' link to verify field detection.
Verify pdftk is installed on your server and accessible. Try specifying the full path (e.g., /usr/bin/pdftk) in FillPDF settings. Run 'pdftk --version' on command line to test.
Check that the Docker container is running and the endpoint URL is correct. The default endpoint for local Docker is http://127.0.0.1:8085. Verify firewall settings allow the connection.
Set a filename pattern on the FillPDF form edit page. The pattern supports tokens - use tokens like [node:title] for dynamic filenames.
Verify the correct entity type is specified in the URL parameters. Check that the token syntax is correct. Use the token browser on the field edit form to select valid tokens.
Image support requires FillPDF Service or LocalServer backends. PDFtk backend does not support image fields. Ensure the image token resolves to a valid file path.
The previously configured storage scheme may no longer exist. Go to FillPDF settings and update the template_scheme. You may need to move PDF template files to the new location manually.
Security Notes 6
- The 'publish all pdfs' permission allows users to access any entity's data through PDF generation. Grant this permission carefully.
- Public file storage (public://) does not provide access control. Use private:// for PDFs containing sensitive information.
- PDF encryption via PDFtk only works with the pdftk backend. Other backends do not support encryption.
- Always set an owner password when using encryption - otherwise anyone can change security settings.
- FillPDF Service transmits PDF data over the network. Use HTTPS and consider data sensitivity before using remote backends.
- Validate that entity access controls are properly configured - FillPDF respects entity access but with 'publish all pdfs' permission, users can generate PDFs for any entity.