Skip to main content
Version: 3

Configuration Options

All configuration should be added to your /wp-content/uploads/PDF_EXTENDED_TEMPLATES/configuration.php file. Multisite installations will have an extra directory in the PDF templates folder which are named with each website's ID number - /wp-content/uploads/PDF_EXTENDED_TEMPLATES/5/configuration.php.
Gravity PDF 3.6.0 moved the PDF_EXTENDED_TEMPLATES folder from your active theme to your uploads directory.
BASIC USAGE

It is simple to generate PDFs and have them attached to Gravity Form notifications. The following will send the default PDF template to all form notifications.

$gf_pdf_config[] = array(
'form_id' => 1,
'notifications' => true,
);

It's worth noting that each 'block' or 'node' as we like to call them is representative of one PDF. If you add a second node with the same form ID as the first you are creating two separate PDFs. If you would like to apply multiple options to a single node you can.

DEFAULT TEMPLATE-ONLY CONFIGURATION
You can exclude fields from the default PDF template by adding the class name exclude to the field's Custom CSS Class option (in the fields Appearance or Advanced tab).
Users can use these options to change the look and feel of any of the default template files (any template prepended with default-) to change their look and feel.Description:
  • default-show-html - This option will display HTML blocks in your default template (added in v3.1.0).
  • default-show-empty - All form fields will be displayed in the PDF, regardless of what the user input is (added in v3.1.0).
  • default-show-page-names - If you are using page breaks you can display the page names in the PDF (added in v3.1.0).
  • default-show-section-content - By default only the section break title is displayed in the PDF. Enabling this option will also show the section break content (added in v3.7).
/* set individual options for default templates */
$gf_pdf_config[] = array(
'form_id' => 1,
'template' => 'default-template.php',
'default-show-html' => true,
);

$gf_pdf_config[] = array(
'form_id' => 1,
'template' => 'default-template.php',
'default-show-empty' => true,
);

$gf_pdf_config[] = array(
'form_id' => 1,
'template' => 'default-template.php',
'default-show-page-names' => true,
);

$gf_pdf_config[] = array(
'form_id' => 1,
'template' => 'default-template.php',
'default-show-section-content' => true,
);

/*
* Or use a combination of the new options to achieve the results you want
*/
$gf_pdf_config[] = array(
'form_id' => 1,
'template' => 'default-template.php',
'default-show-html' => true,
'default-show-empty' => true,
'default-show-page-names' => true,
'default-show-section-content' => true,
);
ATTACH DEFAULT TEMPLATE TO NOTIFICATION

By default the software doesn't attach PDFs to notifications. By using the notifications option you can choose to attach PDFs to all notifications of a form, or restrict it to particular notifications.

/* only send default template to the notification called Admin Attachment */
$gf_pdf_config[] = array(
'form_id' => 1,
'notifications' => 'Admin Notification',
);

/* multiple attachments but not all */
$gf_pdf_config[] = array(
'form_id' => '1',
'notifications' => array('Admin Notification', 'User Notification'),
);

/* attach PDF to all form notifications */
$gf_pdf_config[] = array(
'form_id' => '1',
'notifications' => true,
);
CUSTOM PDF NAME

Using this option you can change the PDF name and even use MERGETAGS to customise the PDFs for each user.

Note: The MERGETAG {all_fields} will not be processed.
Note: Remember to add .pdf to the end of your custom PDF name
$gf_pdf_config[] = array(
'form_id' => '1',
'notifications' => true,
'filename' => 'User {Name:1}.pdf',
);
CUSTOM TEMPLATE
Please see our dedicated documentation page which discusses how to create a custom template file.
You can set the custom template using the template parameter.
$gf_pdf_config[] = array(
'form_id' => 1,
'template' => 'example-template.php',
);

CUSTOM PDF SIZE AND ORIENTATION

You can change the default size of your PDF from A4 to a number of pre-defined sizes, including letter and legal, or use a custom size. You are also able to change if the document is landscape or portrait.

Note: PDF size presets include: A0 - A10, B0 - B10, C0 - C10, 4A0, 2A0, RA0 - RA4, SRA0 - SRA4, Letter, Legal, Executive, Folio, Demy and Royal
/* generate a PDF the size of US letter in landscape */
$gf_pdf_config[] = array(
'form_id' => 1,
'pdf_size' => 'letter',
'orientation' => 'landscape',
);

/* generate an A3 PDF document */
$gf_pdf_config[] = array(
'form_id' => 1,
'pdf_size' => 'A3',
);

/* generate a custom PDF (specified in millimeters) */
$gf_pdf_config[] = array(
'form_id' => 1,
'pdf_size' => array(150, 250),
);
RTL LANGUAGE SUPPORT

mPDF supports a range of languages out of the box and if you are generating PDFs in RTL languages like Arabic or Hebrew you can call the RTL parameter to correctly display text in your PDF.

Note: If you want to output PDFs in Japanese, Korean or Chinese you will need to install additional fonts.
$gf_pdf_config[] = array(
'form_id' => 1,
'rtl' => true,
);
PDF SECURITY

You can easily restrict what users can do with generated PDFs by applying privileges to the document. You can also password protect it and set a master password to prevent any of the security settings being modified.

To enable the security methods you first need to set the security option to true.

$gf_pdf_config[] = array(
'form_id' => 1,
'notifications' => true,

'security' => true,
'pdf_password' => 'myPDFpass', /* remember to CHANGE this */
'pdf_privileges' => array('copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres'),
'pdf_master_password' => 'admin password', /* remember to CHANGE this */
);
Warning: If pdf_master_password is omitted a random one will be generated
Note: Passing a blank array or not passing anything to pdf_privileges will deny all permissions to the user.
Note: Valid privileges include: copy, print, modify, annot-forms, fill-forms, extract, assemble, print-highres
Note: The use of print will only allow low-resolution printing from the document; you must specify print-highres to allow full resolution printing.
CREATE PDF/A-1b DOCUMENTS
Added in v3.4.0
PDF/A1-b is a file format for the long-term archiving of electronic documents. A key element to this reproducibility is the requirement for PDF/A documents to be 100% self-contained.

The software will automatically make appropriate changes to your document to generates a valid PDF/A-1b document, however the following items cannot be automatically fixed and are disallowed:

  1. Watermarks - text or image - are not permitted (transparency is disallowed so will make text unreadable)
  2. PNG images with alpha channel transparency ('masks' not allowed)
Important: The software is not guaranteed to produce fully PDF/A1-b compliant files in all circumstances. It is the users responsibility to check compliance if this is essential.
Note: The security features aren't compatible with PDF/A-1b and will be automatically removed.
$gf_pdf_config[] = array(
'form_id' => 1,
'pdfa1b' => true,
);

You can read more about generating a PDF/A1-b document on the mPDF website.

CREATE PDF/X-1a DOCUMENTS
Added in v3.4.0
PDF/X-1a is a file format to facilitate printing of electronic documents. Two key elements to this function are the requirement for PDF/X-1a documents to be 100% self-contained, and all images need to be CMYK or spot colors.

The software will automatically make appropriate changes to your document to generates a valid PDF/X-1a document, however the following items cannot be automatically fixed and are disallowed:

  1. Watermarks - text or image - are not permitted (transparency is disallowed so will make text unreadable)
  2. PNG images with alpha channel transparency ('masks' not allowed)
Important: The software is not guaranteed to produce fully PDF/X-1a compliant files in all circumstances. It is the users responsibility to check compliance if this is essential.
Note: The security features aren't compatible with PDF/X-1a and will be automatically removed.
$gf_pdf_config[] = array(
'form_id' => 1,
'pdfx1a' => true,
);

You can read more about generating a PDF/X-1a document on the mPDF website.

SAVE PDF TO SERVER
Added in 3.4.0
Use this option if you want to save the PDF to your server when an entry is submitted. This is useful if you aren't sending PDF notifications (which need to save the PDFs so they can be attached to emails) and would still like the PDFs generated.
$gf_pdf_config[] = array(
'form_id' => 1,
'save' => true,
);
SET IMAGE DPI
Added in v3.4.0
Note: The default DPI is 96
For when you need control over the image DPI - which is usually set to 300 when used in professional printing.
$gf_pdf_config[] = array(
'form_id' => 1,
'dpi' => 300,
);
ADVANCED USAGE

You can generate and attach multiple PDFs on the same form by creating two different configuration arrays using the same form_id.

Warning: You need to explicitly set the filename when using this method otherwise the default file name will be used and only generate one PDF.
$gf_pdf_config[] = array(
'form_id' => 1,
'notifications' => true,
'template' => 'custom-template.php',
'filename' => 'Custom.pdf',
);

$gf_pdf_config[] = array(
'form_id' => 1,
'notifications' => true,
'template' => 'custom2.php',
'filename' => 'Custom Template 2.pdf',
);
DEFAULT CONFIGURATION OPTIONS
Warning: The default configuration settings will only work if the configuration option GFPDF_SET_DEFAULT_TEMPLATE is set to true.
Users have the ability to set default configuration options for all forms that you haven't explicitly set a configuration for. Users can use any configuration option which you would use in the normal configuration.
global $gf_pdf_default_configuration;

$gf_pdf_default_configuration = array(
'template' => 'default-template.php',
'pdf_size' => 'A4',
);
PUTTING IT ALL TOGETHER

We've put together an example that uses all the configuration options (minus the default template-specific options) for Gravity PDF.

$gf_pdf_config[] = array(
'form_id' => 1,
'notifications' => array('My Notification 1', 'My Notificaiton 2'),
'template' => 'custom-template.php',
'filename' => '{date_mdy}_Custom.pdf',

'rtl' => true,

'pdfsize' => 'A10',
'orientation' => 'landscape',

'security' => true,
'pdf_password' => 'mypass', /* remember to CHANGE this */
'pdf_privileges' => array('print', 'fill-forms', 'print-highres'),
'pdf_master_password' => 'admin password', /* remember to CHANGE this */
);

Settings

PropertyDefaultTypeExampleDescription
form_idN/AMixed - Integer/Array1 or array(1,2,5)The ID of the form you want to apply the PDF configuration to. The only required option.
default-show-html (v3.1.0+)falseBooleantrue or falseThis option will display HTML blocks in your default template.
default-show-empty (v3.1.0+)falseBooleantrue or falseAll form fields will be displayed in the PDF, regardless of what the user input is.
default-show-page-names (v3.1.0+)falseBooleantrue or falseIf you are using page breaks you can display the page names in the PDF.
default-show-section-content (v3.7+)falseBooleantrue or falseEnabling this option will also show the section break content.
notifications N/AMixed - String/Array/Boolean"Admin Notification", array('Not 1', 'Not 2') or true.The notifications you want to attach the PDF to. Leave blank will not attach PDF to notification.
templateDefault-template.phpString"my-custom- template.php"The template file used to generate the PDF document. Note: PDF templates are located in your active theme's PDF_EXTENDED_TEMPLATES folder.
filename form-{form_id}- entry-{entry_id}.pdfString"My Custom Name.pdf" or " User {Name:1}.pdf"Change the name of the PDF file. You can now use a form's MERGE TAGS in the file name.
pdf_size A4Mixed - String/Array"Letter", "A10" or array(50, 200)Sets the PDF size. Can pass a string with pre-defined size or an array which sets the PDF width and height in millimetres. PDF Presets A0 - A10, B0 - B10, C0 - C10, 4A0, 2A0, RA0 - RA4, SRA0 - SRA4, Letter, Legal, Executive, Folio, Demy, Royal
orientation PortraitString"landscape"Change the orientation of the PDF to landscape. Note: By default the orientation is portrait so you only need to add it for landscape PDFs
rtl FalseBooleanTrueChange the text direction from right to left for languages like Hebrew and Arabic
pdfa1b (v3.4.0+)falseBooleantrue or falseChanges the PDF output to a PDF/A-1b document
pdfx1a (v3.4.0+)falseBooleantrue or falseChanges the PDF output to a PDF/X-1A document
save (v3.4.0+)falseBooleantrue or falseSave the PDF to your server on form submission.
dpi (v3.4.0+)96Integer300Changes the image DPI. 96 is a good default, but it should be changed to 300 if the document is to be professional printed
security FalseBooleanTrueDetermines whether to restrict access to PDF. Use in conjunction with pdf_master_password, pdf_password and pdf_privileges.
pdf_master_passwordN/AString"aSAja4202$@@"Restricts modification of the PDF document. If omitted a random password will be generated.
pdf_passwordN/AString"U5erPa55w%rd"Restricts access to a PDF. If you pass an empty string there won't be a password on the PDF.
pdf_privilegesN/AArrayarray('copy', 'print', 'modify', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-highres')Restricts what users are able to do with the PDF. Note: The use of print will only allow low-resolution printing from the document; you must specify print-highres to allow full resolution printing. Note: Passing a blank array or not passing anything to pdf_privileges will deny all permissions to the user

Advanced Configuration

At the bottom of the configuration.php file is a number of constants that modify advanced program settings - most related to reducing the software's memory footprint. View the memory footprint portion of the documentation for more information about reducing memory usage.
PropertyDefaultTypeExampleDescription
GFPDF_SET_DEFAULT_TEMPLATETrueBooleanfalseBy default, forms that don't have PDFs assigned through the above configuration will automatically use the default template in the admin area. Set to false to disable.
PDF_ENABLE_MPDF_LITEFalseBooleantrueReduce the memory footprint by disabling advanced features like advanced table borders, terms and conditions, columns, index, bookmarks and barcodes.
PDF_ENABLE_MPDF_TINYFalseBooleantrueFurther reduce memory footprint by disabling all the features of Lite plus positioning, float, watermark and form support
PDF_DISABLE_FONT_SUBSTITUTIONFalseBooleantrueDisable font substitution. The entire font file will be embedded in PDF. Note: embedding entire font files increases PDF file size.
PDF_ENABLE_SIMPLE_TABLESFalseBooleantrueDisable the advanced table feature and forces all cells to have the same border and background