Title: Plugin Not Creating nor Saving PDF
Last modified: August 21, 2016

---

# Plugin Not Creating nor Saving PDF

 *  [kenedyt](https://wordpress.org/support/users/kenedyt/)
 * (@kenedyt)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/plugin-not-creating-nor-saving-pdf/)
 * Member
    Posted 42 minutes ago #
 * Hello, i have the same problem, still not working for me, I have version 2.2.3
   and GF 1.7.2.
 * I double checked everything, inserted this code in functions.php inside my theme
   files, before php tag, please take a look. The PDF is not being created neither
   attached. I used the ID and the tittle when needed. Wrote the notification tittle
   for the user and the admin:
 *     ```
       function gfpdfe_create_and_attach_pdf($notification, $form, $entry)
       {
   
           /*
            * Set the PDF name here or leave blank to use the default.
            * Example: $PDF_name = 'My Custom Document.pdf';
            */
           $PDF_name = 'My Custom Document.pdf';
   
           /*
            * Use a custom template or leave blank to use the default.
            * The template file needs to be in your active theme's PDF_EXTENDED_TEMPLATES folder before referencing below
            * Example: $custom_template_name = 'my-custom-template.php';
            * Default template options: default-template.php, default-template-two-rows.php, default-template-no-style.php
            */
           $template_name = 'default-template.php';
   
           /*
            * Set data used to determine if PDF needs to be created and attached to notification
            * Don't change anything here.
            */
           $notification_name = $notification['name'];
           $notification_id   = $notification['id'];
           $form_title        = $form['title'];
           $form_id           = $entry['form_id'];
           $user_id           = $entry['id'];
           $folder_id = $form_id.$user_id.'/';
   
           /* GENERATE AND EMAIL PDF
            * Do we want to create and send a PDF for this form?
            * You can match the form ID or the form title
            * Example: if($form_id == 2 || $form_title == 'Let me Know What Do You Need')
            */
           if ($form_title == 'Let me Know What Do You Need') {
               /*
                * Get ready to create the PDF file
                */
                require PDF_PLUGIN_DIR . 'render_to_pdf.php';
                $PDF_name          = (strlen($PDF_name) > 0) ? $PDF_name : get_pdf_filename($form_id, $user_id);
                $pdf_arguments     = array(
                    'pdfname' => $PDF_name,
                    'template' => $template_name,
                    'return' => true
                );
   
               /* generate and save default PDF */
               $filename = PDF_Generator($form_id, $user_id, $pdf_arguments);
   
               /* ATTACH PDF TO EMAIL
                * As of GF 1.7 notifications aren't limited to admin and user.
                * We now need to match the notification we would like to attach the file to instead of using gform_admin_notification_attachments and gform_user_notification_attachments.
                * You can match against the name of your notification
                * Example: if($notification_name == 'Admin - Notify admin user')
                */
               if ($notification_name == 'Admin Notification' || $notification_name == 'User Notification') {
                   $attachment_file               = PDF_SAVE_LOCATION . $folder_id . $PDF_name;
                   $notification['attachments'][] = $attachment_file;
               }
           }
           return $notification;
       }
   
       add_filter('gform_notification', 'gfpdfe_create_and_attach_pdf', 10, 3);
   
       <?php }
       ?>
       ```
   
 * Please help… I couldn’t make this work for me.
 * [http://wordpress.org/extend/plugins/gravity-forms-pdf-extended/](http://wordpress.org/extend/plugins/gravity-forms-pdf-extended/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Jake Jackson](https://wordpress.org/support/users/blue-liquid-designs/)
 * (@blue-liquid-designs)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/plugin-not-creating-nor-saving-pdf/#post-3708772)
 * Hi Kenedyt,
 * You need to place the function inside the PHP tags <?php function…. ?>
 * Secondly, you should match to the form ID not the form title – change: _if ($
   form\_title == ‘Let me Know What Do You Need’) {_ to _if ($form\_id == 3) {_.
 * If you are still having problems please follow steps 4 and 5 here: [http://gravityformspdfextended.com/topic/pdf-not-working-please-read-before-starting-a-new-topic/](http://gravityformspdfextended.com/topic/pdf-not-working-please-read-before-starting-a-new-topic/)
 *  Thread Starter [kenedyt](https://wordpress.org/support/users/kenedyt/)
 * (@kenedyt)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/plugin-not-creating-nor-saving-pdf/#post-3708820)
 * Thankyou! Amazing… I love this plugin…
 *  [coryhubbell](https://wordpress.org/support/users/coryhubbell/)
 * (@coryhubbell)
 * [13 years ago](https://wordpress.org/support/topic/plugin-not-creating-nor-saving-pdf/#post-3709053)
 * K feeling like im really close here can i get some help on what im missing on
   my code:
 *     ```
       /*************************************************************************************
        *	Gravity forms pdf writer
        *************************************************************************************/
       function gfpdfe_create_and_attach_pdf($notification, $form, $entry)
       {
   
           /*
            * Set the PDF name here or leave blank to use the default.
            * Example: $PDF_name = 'My File.pdf';
            */
           $PDF_name = 'Customer Information.pdf';
   
           /*
            * Use a custom template or leave blank to use the default.
            * The template file needs to be in your active theme's PDF_EXTENDED_TEMPLATES folder before referencing below
            * Example: $custom_template_name = 'my-custom-template.php';
            * Default template options: default-template.php, default-template-two-rows.php, default-template-no-style.php
            */
           $template_name = 'default-template.php';
   
           /*
            * Set data used to determine if PDF needs to be created and attached to notification
            * Don't change anything here.
            */
           $notification_name = $notification['name'];
           $notification_id   = $notification['id'];
           $form_title        = $form['title'];
           $form_id           = $entry['form_id'];
           $user_id           = $entry['id'];
           $folder_id = $form_id.$user_id.'/';
   
           /* GENERATE AND EMAIL PDF
            * Do we want to create and send a PDF for this form?
            * You can match the form ID or the form title
            * Example: if($form_id == 3 || $form_title == 'My Custom Form')
            */
           if ($form_id == 7 || $form_title == 'Customer Information') {
               /*
                * Get ready to create the PDF file
                */
                require PDF_PLUGIN_DIR . 'render_to_pdf.php';
                $PDF_name          = (strlen($PDF_name) > 0) ? $PDF_name : get_pdf_filename($form_id, $user_id);
                $pdf_arguments     = array(
                    'pdfname' => $PDF_name,
                    'template' => $template_name,
                    'return' => true
                );
   
               /* generate and save default PDF */
               $filename = PDF_Generator($form_id, $user_id, $pdf_arguments);
   
               /* ATTACH PDF TO EMAIL
                * As of GF 1.7 notifications aren't limited to admin and user.
                * We now need to match the notification we would like to attach the file to instead of using gform_admin_notification_attachments and gform_user_notification_attachments.
                * You can match against the name of your notification
                * Example: if($notification_name == 'Admin - Notify admin user')
                */
               if ($notification_name == 'Admin - Notify admin user' || $notification_name == 'User - Notify User') {
                   $attachment_file               = PDF_SAVE_LOCATION . $folder_id . $PDF_name;
                   $notification['attachments'][] = $attachment_file;
               }
           }
           return $notification;
       }
   
       add_filter('gform_notification', 'gfpdfe_create_and_attach_pdf', 10, 3);
       ```
   
 * Thanks for your help, I have checked to make sure my templates are in the directory
   on the server.
 *  Plugin Author [Jake Jackson](https://wordpress.org/support/users/blue-liquid-designs/)
 * (@blue-liquid-designs)
 * [13 years ago](https://wordpress.org/support/topic/plugin-not-creating-nor-saving-pdf/#post-3709054)
 * Hi,
 * Just looking at the code the first thing I noticed is you haven’t changed the
   notification names:
 * `if ($notification_name == 'Admin - Notify admin user' || $notification_name 
   == 'User - Notify User') {`
 * Make sure you match them to the names of your actual notifications – ie. ‘Administrator
   Notification’.
 * Also, you should really start your own topic for support.
 *  [coryhubbell](https://wordpress.org/support/users/coryhubbell/)
 * (@coryhubbell)
 * [13 years ago](https://wordpress.org/support/topic/plugin-not-creating-nor-saving-pdf/#post-3709055)
 * Thank you and I will do that in the future, my apologies

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Plugin Not Creating nor Saving PDF’ is closed to new replies.

 * ![](https://ps.w.org/gravity-forms-pdf-extended/assets/icon-256x256.png?rev=3168987)
 * [Gravity PDF](https://wordpress.org/plugins/gravity-forms-pdf-extended/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gravity-forms-pdf-extended/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/)
 * [Active Topics](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [coryhubbell](https://wordpress.org/support/users/coryhubbell/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/plugin-not-creating-nor-saving-pdf/#post-3709055)
 * Status: not resolved