Please help: Website generated pdf to attach to notification to customer

Hi. Is there a code I can put into function.php that will allow a notification to have a pdf attachment BUT that file is generated by the website using a “print products” plugin feature? This isn’t a straightforward ‘pick a media file and send it’. The product pdf will change depending on the product the form is sending for. These currently aren’t stored files, but load in a browser.

Scenario: a website product page has a button called ‘product overview’ that when clicked, will load a pdf to either print/save. This contains all the webpage information. I want to attach this specific product generated pdf in a customer notification email, instead of just having a link to the product page in the body of the email.

An example of the product page: NEW HOLLAND BOOMER 20 – COMPACT TRACTOR – Agpower
The link that is the generated product pdf:

What do I need to do to make this possible? (if at all). Thank you so much for any help.

I love the “baby tractors” example product page Kris :slight_smile:

Here are some links that may help you in your goal:

  • The gform_notification filter can let you customize any notification which Gravity Forms is sending out. Example #5 on that page shows adding an attachment based on an upload field.
  • Within that filter could you do a wget or curl to retrieve the generated PDF to be able to attach to the notification.
  • If this is going to apply for multiple forms/fields, that code would need to update with every one you create or you might need to create a custom merge tag to allow more repeatable use.

Speaking of repeatable usage, you could setup the equivalent with less code via Gravity Flow’s flexible Outgoing Webhook.

Using a drop-down field with separate values that match to a portion of your product URL would mean you can use the fields’ merge tag with :value modifier

As the PDF returned isn’t in a standard webhook JSON payload, we would need to use something close to the example #1 snippet from gravityflow_post_webhook action to store the response body into a file on server and update the upload field.

Then the notification can be a separate step in the workflow.

Depending on how/where your webhook action hook stores the file, you may need to use the gform_notification filter linked above or possibly just set the ‘Attach uploaded fields to notification’ setting.

If storage of the files with each entry is a concern, you could use a gravityflow_workflow_complete action to delete the file.

Hope that helps.

Hi Jamie,

Thank you so much for taking the time to reply. This has confirmed for me, it’s not a simple just type in link and it will attach it :slight_smile:

This feature is only on one Gravity form, but will need to generate a file for each time the email is to be sent. So it would create a different pdf, but of the same template.

So I’m trying to work out which of the two methods you proposed is the easiest and most straight forward. I’m am so new to setting up these forms and any php, my head is spinning a little. My developer has been setting all this up for me, but not around anymore, so I’m left to try and figure this out.

I don’t know how to do a wget or curl to retrieve the generated pdf to attach to the notification so will do further research.

In the meantime I’ve done a small workaround by embedding the product pdf into a download icon within the body of the email, until I can figure out how to physically attach it.

Once again, thank you for your expertise. I’ll keep working on it (or find another developer that knows what to do) :slight_smile:


Hi Kristy,

If you purchase Gravity Flow and the suggestions above aren’t enough to help you through, hit up Gravity Flow Support and I or another of our awesome folks will be glad to help get you sorted. It may be a little more volume of code to achieve the same with Gravity Forms alone, but I have no doubt that if you hit up their support they’ll do their best to give you just as much help.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.