Keep up to date with Gravity PDF

  • This field is for validation purposes and should be left unchanged.
Gravity PDF v4 will receive bug fixes and security updates until October 4, 2019, however it's recommended you upgrade to v5 as soon as practical.
Jump To Section

Description #description

This method allows you to create a new PDF on a Gravity Form. If you are inserting data provided by the user ensure you validate and sanitize everything as we don’t do it for you.

Version #version

This method was introduced in Gravity PDF 4.0.

Parameters #parameters

$form_id | integer
The Gravity Form ID
$settings | array
The PDF settings that should be added

Return #return

string | boolean
The new PDF ID on success, false on failure

Usage #usage

This snippet shows the minimum settings that should be passed when adding a new PDF:

add_action( 'init', function() {
    if ( class_exists( 'GPDFAPI' ) ) {

        /* Set up PDF settings */
        $settings = array(
            'name'     => 'API PDF',
            'template' => 'zadani',
            'filename' => 'Custom_Filename_{:2}',
        );

        /* Create a new PDF on form #2 */
        $pdf = GPDFAPI::add_pdf( 2, $settings );

        /* Check if PDF was successfully created */
        if( false !== $pdf ) {
            //Success! $pdf references the new PDF ID
        }
    }
} );

For the full list of settings available see the form_settings, form_settings_appearance and form_settings_advanced arrays in the Helper_Options_Fields::get_registered_fields() method.

Source Code #source-code

This method is located in api.php.

Signup for the latest Gravity PDF news, tips and updates

  • This field is for validation purposes and should be left unchanged.
Scroll To Top

Choose your currency:

Close
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 (¥)