Skip to main content
Version: v6



This filter gives you access to the mPDF object after the initial PDF setup code has finished running, and before the template HTML has been generated/loaded.


If using a Core or Universal PDF template, writing content directly to the PDF using this filter can break the Header and Footer display.


This filter was introduced in Gravity PDF 5.1.5.


$mpdf | object

  • The initialised mPDF class that handles the PDF generation

$form | array

  • The current Gravity Forms array

$entry | array

  • The raw Gravity Forms Entry array.

$settings | array

  • The current PDF settings being processed

$Helper_PDF | object

  • The initialised \GFPDF\Helper\Helper_PDF class


Write content directly to the PDF:

add_filter( 'gfpdf_mpdf_init_class', function( $mpdf, $form, $entry, $settings, $Helper_PDF ) {
$mpdf->WriteHTML( 'This is included right at the beginning of the document...' );

return $mpdf;

}, 10, 5 );

Change the default zoom level of the PDF to 100%:

add_filter( 'gfpdf_mpdf_post_init_class', function( $mpdf ) {
// See for valid inputs

return $mpdf;
} );

Source Code

This filter is located in the Helper_PDF::begin_pdf() method of /src/helper/Helper_PDF.php.