FillPDF

Allows users to populate fillable PDF forms with data from Drupal entities.

fillpdf
2,247 sites
61
drupal.org

インストール

Drupal 11, 10 v5.2.1
composer require 'drupal/fillpdf:^5.2'
Drupal 9 v5.1.1
composer require 'drupal/fillpdf:^5.1'

概要

FillPDFは、Drupalサイトのデータを使用して入力可能なPDFフォームに自動的にデータを入力できる強力なモジュールです。トークンベースのフィールドマッピングをサポートしており、PDFフォームフィールドをNode、User、Webform、その他のコンテンツエンティティのデータにマッピングできます。

このモジュールは、PDFtk(ローカルインストール)、FillPDF LocalServer(DockerベースのAPI)、FillPDF Service(リモートAPI)など、柔軟なPDFバックエンドオプションを提供します。生成されたPDFは、直接ダウンロード、ファイルシステムへの保存、または自動リダイレクトが可能です。

主な機能には、PDFフィールドへの画像挿入、テキストの変換・置換、PDFセキュリティ設定(PDFtkによる暗号化とパーミッション)、サイト間でのフォーム設定のエクスポート・インポート機能が含まれます。

Features

  • トークンベースのフィールドマッピングを使用して、Node、User、Webform、その他のコンテンツタイプのエンティティデータで入力可能なPDFフォームに自動入力
  • 複数のPDF処理バックエンドをサポート:PDFtk(ローカル)、FillPDF LocalServer(Docker)、FillPDF Service(リモートAPI)
  • フィールド名を表示するサンプルPDFを生成し、フィールドの識別とマッピングを容易化
  • 生成されたPDFをファイルシステム(publicまたはprivate)に保存、またはブラウザに直接送信してダウンロード
  • 動的なファイル名パターンと保存先パスのためのトークンサポート
  • PDFに挿入する前に値を変更するためのテキスト変換・置換ルール
  • 暗号化(128ビットまたは40ビット)とユーザーパーミッションを含むPDFセキュリティ機能(PDFtkバックエンド経由)
  • サイト間でのFillPDFフォーム設定とフィールドマッピングのエクスポートとインポート
  • 既存のFillPDFフォーム設定の複製
  • PDFテンプレート内の画像フィールドのサポート
  • フォーム送信からPDFを入力するためのWebformモジュールとの連携
  • FillPDFフォームとフィールドを管理するためのViewsとの連携
  • フォームの動作とPDF入力コンテキストを変更するためのhook

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
FillPDF settings /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.

FillPDF /admin/structure/fillpdf

Main overview page for managing FillPDF forms. Lists all uploaded PDF templates and provides the interface to upload new templates.

Edit FillPDF form /admin/structure/fillpdf/{fillpdf_form}

Edit a FillPDF form's settings and manage field mappings. Configure how the PDF is populated with entity data.

Edit FillPDF form field /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.

Export FillPDF form configuration /admin/structure/fillpdf/{fillpdf_form}/export

Export the FillPDF form configuration and field mappings as JSON code for importing on another site.

Import FillPDF form configuration /admin/structure/fillpdf/{fillpdf_form}/import

Import field mappings from another FillPDF form. Useful for copying configurations between sites.

Duplicate FillPDF form /admin/structure/fillpdf/{fillpdf_form}/duplicate

Create a copy of an existing FillPDF form including all its field mappings.

権限 3
Administer PDFs

Allows usage of FillPDF administration screens. Users with this permission can manage PDF templates, configure field mappings, and access FillPDF settings.

Publish own PDFs

Allows filling in and downloading PDFs with the user's own site content. Users can only populate PDFs with entities they own or have access to.

Publish all PDFs

Allows filling in and downloading PDFs with any site content. Users can populate PDFs with any entity regardless of ownership.

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
PDF fields are not being detected after upload

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.

PDFtk backend shows 'not properly installed' error

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.

FillPDF LocalServer cannot be contacted

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.

Generated PDF filename shows 'untitled.pdf'

Set a filename pattern on the FillPDF form edit page. The pattern supports tokens - use tokens like [node:title] for dynamic filenames.

Token values not appearing in generated PDF

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.

Images not appearing in PDF fields

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.

Storage scheme is unavailable after server migration

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.