Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Configuration Language Lock 1.0.2 Minor update available for module config_language_lock (1.0.2). Release: Canvas Override 1.0.1 Minor update available for module canvas_override (1.0.1). Release: Media Remote Image 8.x-1.2 Minor update available for module media_entity_remote_image (8.x-1.2). Release: IDNA Convert Service (punycode) 2.0.4 Minor update available for module idna (2.0.4). Release: Bootstrap Cloud 7.1.3 Minor update available for theme bootstrap_cloud (7.1.3). Release: Token Browser 1.0.2 Minor update available for module token_browser (1.0.2). Release: Varbase Project 11.0.8 Minor update available for module varbase_project (11.0.8). Release: Media Remote Image 2.0.0-beta1 First beta version released for module media_entity_remote_image (2.0.0-beta1). Usage Milestone: Term CSV Export Import Module term_csv_export_import crossed 1,000 active installs. Security Coverage: Module Scout Module module_scout now has official Drupal security advisory coverage.

PDF printing with template

96 sites Security covered Drupal 9–11
View on drupal.org

This module enables the generation of PDF files for printing based on a template. It allows you to import pages from existing PDF documents and insert view content, custom text, images, or HTML onto specified positions within the template.

This module uses library FPDI Generate a PDF file for printing based on a template.
You can import pages from existing PDF documents.

How to use:

  1. install module fpdi_print with composer require drupal/fpdi_print. It'll add libraries tcpdf & fpdi to vendor
  2. Create view page node with contextual filter (nid)
  3. Add Pdf Print (global) to Header or Footer Views page
    • Fill all the configuration
    • Path to pdf source file - version 1.4. /!\ Check your version pdf before upload, it doesn't work with version 1.5 or 1.6 Path asbolute /var/www/drupal/sites/default/files/template.pdf or relative sites/default/files/template.pdf
    • Add position x,y, text (format array yaml) /!\check validation yaml or /fpdi-print/validate before paste

If you leave the position configuration empty. It'll print contents of the view. You can set pdf header footer with global area custom text from views header footer
Example:

If your fpdf is Form filling and compatible (FPDM)
you can set configuration like this (you don't need position x,y)

- form: "address"
  text: "My city"
- form: "address"
  text: "My phone number"

You can goto page /fpdi-print/validate to check pdf and yaml format

for developper

There is hook fpdi_print_views for alter data positions before generate.
you can call service fpdi_print.print_builder
Format of positions : page number => [ x , y , (text|html|image), height , width]
the page number must start with 1 (NOT BEGIN WITH 0)

/*
$positions = [
 '1' => [
     [ 'x'=> 10, 'y'=>20, 'text'=>'Show text in page 1'],
     [ 'x'=> 15, 'y'=>40, 'height'=>50 , 'width'=>50, 'image'=>101 //you can add fid for image],
     [ 'x'=> 15, 'y'=>50,  'image'=>'/path/to/image' // add image path],
     [ 'x'=> 15, 'y'=>60,  'image'=>'<img src="/path/to/image1.png"/> <img src="/path/to/image2.jpg"/>'// add html multi images],
],
 '2' => [
     [ 'x'=> 10, 'y'=>20, 'height'=> 10, 'html'=>'Show <b>html</b>\n in page 2' ],
]
 '3' => [
     [ 'pdf'=>'/path/to/merge/file.pdf' ],
]
]
*/

    $pdf = \Drupal::service('fpdi_print.print_builder')->getPDF($positions, $filePdfTemplate);

//you can save pdf to file with $pdf->Output('I','yourFileName.pdf');
//or show in directly to browser 
    $response = new StreamedResponse();
    return $response->setCallback(function () use ($pdf) {
      ob_clean();
      $handle = fopen('php://output', 'w+');
      $pdf->Output();
      fclose($handle);
    });

Hook avaible before render pdf


/**
 * Implements hook_fpdi_print_views_alter().
 */
function myModule_fpdi_print_views_alter($dataPositions, $view, $filePdfTemplate){
  $view_id = $view->id();
...
}

Do you like this module? Show your appreciation by buying me ☕.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Apr 2026
Latest release
1 month ago
Releases (12 mo)
5 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.1.19 Stable 9–11 Jul 24, 2026
1.1.18 Stable 9–11 Jul 4, 2026
1.1.7 Stable 9–11 Apr 24, 2026
1.1.6 Stable 9–11 Apr 24, 2026
1.1.5 Stable 9–11 Apr 24, 2026