Creating Long-term Download Links for Filled PDFs
Overview
In some situations, you may need to provide a long-term download link to the filled PDF after a user completes your form, rather than attaching the PDF to an email notification or providing a temporary download link in the form confirmation.
There are several ways to provide these links to users:
- Include a link in the email notification the user receives after submitting the form
- Add a link on the thank you page or confirmation that appears after form submission
The need for providing a link rather than attaching the filled PDF might arise due to the large size of the generated PDF file and email attachment limitations.
Implementation Methods
Adding Links to Emails or Form Confirmations
The first step is to set up your form to save the filled PDFs at a specific path on your server:
- Navigate to your form’s settings and select the PDF Forms tab
- Find your attached PDF file and click the Options button
- In the Path for saving filled PDF file field, enter a path where you want to save the files
- You can use Smart Tags as part of the path to create unique directories for each submission
For example, if you set the save path option to my-pdfs/{unique_value}
and set the filename to document
, your filled PDF file will be stored at wp-content/uploads/my-pdfs/12345/document.pdf
(where 12345
would be a unique value).
You can then provide a link to this file in your email notification or form confirmation message using the same Smart Tags:
{site_url}/wp-content/uploads/my-pdfs/{unique_value}/document.pdf
Important: Ensure you use a path and filename combination that creates unique files. If a file with a matching name already exists, a numerical identifier will be appended (e.g.,
document-1.pdf
), which could cause your links to point to the wrong file.
Security Consideration: Using predictable paths can pose a security risk as it might allow unauthorized access to your users’ files. Make sure the save directory has indexing disabled and use Smart Tags that create hard-to-guess paths.
Adding Links to Thank You Pages
For more advanced implementations where you want to provide download links on custom thank you pages, you’ll need to:
- Save the PDF with a unique identifier in the path
- Pass that identifier to your thank you page
- Use the identifier to construct the download link on the thank you page
Using WPForms Unique Entry ID
WPForms creates a unique entry ID for each submission. You can use this to create secure download links:
-
Configure your PDF attachment options:
New filled PDF file name: document.pdf Path for saving filled PDF file: my-pdfs/{entry_id}/
-
Set up a custom confirmation that redirects to your thank you page and passes the entry ID:
https://example.com/thank-you/?entry_id={entry_id}
-
On your thank you page, create a download link that uses the entry ID from the URL parameter:
<a href="/wp-content/uploads/my-pdfs/<?php echo sanitize_text_field($_GET['entry_id']); ?>/document.pdf" target="_blank" rel="noreferrer noopener">Download Your PDF</a>
Security Considerations
To ensure the security of your users’ filled PDFs:
- Make sure directory indexing is disabled on your server
- Consider adding an .htaccess file to the uploads directory to restrict access
- Validate the entry ID on your thank you page before displaying the download link
- Use HTTPS for all pages that contain sensitive information
- Consider implementing a time limit for how long the files are available