Keep up to date with Gravity PDF

  • This field is for validation purposes and should be left unchanged.
This is the documentation for version 4 of Gravity PDF. See version 3 docs here.

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