Skip to main content
Version: v6

How to integrate Setasign FPDI PDF-Parser with Gravity PDF

Because Gravity PDF prefixes the PHP namespaces for all composer-managed files (to prevent conflicts with other plugins), special consideration needs to be taken if you would like to integrate the Setasign FPDI PDF-Parser with Gravity PDF.


Gravity PDF does not provide free support to developers who want to auto-fill existing PDFs with Gravity PDF. If you are interested in that feature, you can utilise Gravity PDF's Bespoke PDF service or pay for premium support.

To add support, right after you add the autoloading code for the PDF-Parser you need to include these class aliases:

require_once __DIR__ . '/FPDI_PDF-Parser/src/autoload.php';

/* Alias our vendor prefixed classes back to their original class name */
$alias = [

foreach( $alias as $class ) {
class_alias( '\GFPDF_Vendor' . $class, $class );

/* Alias the commercial FPDI Parser classes to our prefixed class name */
$alias = [

foreach( $alias as $class ) {
class_alias( $class, '\GFPDF_Vendor' . $class );

Where possible, it's best to include these aliases just before you begin using Gravity PDF. This will reduce the chance of conflicting with another plugin that includes the same libraries.