Display PDF in Browser
The generated PDF can easily and securely be displayed in a users browser once the form has been submitted using the Gravity Form redirect setting.
Security
Before we discuss these methods just a note on security. To prevent unwanted users accessing sensitive data each PDF displayed using this method will check three things:- If the user is logged in and their user ID matches the ID on the entry.
- Or, if the user's IP address matches the IP address on file for the entry.
- Or, if an administrator is logged in with read privileges for Gravity Forms entries.
Passing Form Values
You'll need to pass all of the following values to a URL you create in order to display the PDF in the browser:fid={form_id}
lid={entry_id}
gf_pdf=1
template=custom-template.php
The fid
and lid
parameters take information using Merge Tags, gf_pdf
won't change and template will refer to the template file you would like to use when generating the PDF.
Example
Text Confirmation Method
You can pass in the appropriate values to the 'text' confirmation and allow users to download a copy of the PDF right after submitting their form.Page Confirmation Method
This option is more complex than the other two options as you need to install a third party plugin which allows you to use the URL parameters in the page you point to.First download and install the URL Params plugin. Next, go to your form's confirmation page and configure it to look like the screenshot below.
Set you form's configuration settings like so. You can point to any page you like.
Finally, go to your WordPress page you linked to and, using the PDF Params plugin, you can construct the PDF link and access the form ID and entry ID parameters.
<a href="[urlparam param="lead_id"]">
. The simple fix is to remove the quotes from the shortcode - this is valid: <a href="[urlparam param=lead_id]">
.Redirect Confirmation Method
You can automatically redirect users to the generated PDF right after submitting their form
Automatically print when PDF is opened
By adding &print=1 to the URL a print dialog box will automatically open when the PDF does.
To automatically force a print dialog box to be displayed when the PDF is viewed or downloaded from your website you can append &print=1
to your PDF link.