Keep up to date with Gravity PDF

  • This field is for validation purposes and should be left unchanged.
This is the legacy Gravity PDF v4 documentation which is NOT supported. Go to the latest documentation.
Jump To Section

Description #description

This filter can be used to include additional content directly in your PDF, or override any existing PDF settings Gravity PDF defaults to. This filter is run after the PDF template’s HTML is loaded into mPDF and right before the document is generated. If you want to change any of mPDF’s rendering settings you should use the gfpdf_mpdf_init_class filter instead, as it gives you access to the class right after being initialised.

Parameters #parameters

$mpdf | object
The initialised mPDF class that handles the PDF generation
$form | array
The current Gravity Form array
$entry | array
The raw Gravity Form Entry array.
$settings | array
The current PDF settings being processed
$Helper_PDF | object
The initialised \GFPDF\Helper\Helper_PDF class

Usage #usage

The snippet below will output additional debugging information to the end of the PDF when WordPress has debugging mode enabled:

add_filter( 'gfpdf_mpdf_class', function( $mpdf, $form, $entry, $settings, $Helper_PDF ) {

    /* You might want to include additional debugging information if WP_DEBUG is true */
    if( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
        $mpdf->WriteHTML( 'Debug Information: ...' );

    return $mpdf;

}, 10, 5 );

You might also like to change the display mode from the ‘fullpage’ setting we default to:

add_filter( 'gfpdf_mpdf_class', function( $mpdf, $form, $entry, $settings, $Helper_PDF ) {

     * Let's change the PDF display mode from fullpage to fullwidth
     * We could have called $mpdf->SetDisplayMode( 'fullwidth', 'continuous' ); directly, but since we have a public
     * method available in $Helper_PDF that does just that we'll use it instead.
    $Helper_PDF->set_display_mode( 'fullwidth' );

    return $mpdf;

}, 10, 5 );

Source Code #source-code

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

Signup for the latest Gravity PDF news, tips and updates

  • This field is for validation purposes and should be left unchanged.
Gravity PDF 40K Active Installs Celebration! Take 20% off any products with coupon 40KMILESTONE (this week only)Visit Store
+ +
Scroll To Top

Choose your currency:

Converted prices are for reference only - all orders are charged in $ Australian Dollars ($) AUD.
  • AUDAustralian Dollars ($)
  • USDUS Dollars ($)
  • CADCanadian Dollars ($)
  • EUREuros (€)
  • GBPPound Sterling (£)
  • NZDNew Zealand Dollar ($)
  • JPYJapanese Yen (¥)