PDF Form Submissions

With the Convert Forms PDF Form Submissions addon, you can create customizable PDFs when a user submits your Joomla Form. With one simple shortcode, the PDF files can be then attached to emails, displayed as a download link in the Thank you Message or even uploaded to popular storage apps like Google Drive or Dropbox.

Setup PDF Form Submission

If you have Convert Forms Pro, log into your backend, open your form in the form editor and from the form settings in the left sidebar, navigate to Behavior -> PDF Form Submission and click on Enable PDF Form Submission.

If you can’t find the PDF Form Submission panel, make sure you’re using Convert Forms Pro 2.6.0+ and the Convert Forms - PDF Form Submission plugin is enabled in the Plugins Manager.

After you’ve enabled the PDF Form Submission, you will see 4 options appearing below.

PDF Template

Specify the actual content that will appear in the PDF. You can write your own HTML, use Smart Tags, add your own images as well as use inline CSS styling.

PDF Folder

Select the folder relative to your root directory where the generated PDFs will be stored. You can use Smart Tags to have a dynamic folder. For instance, by settings the PDF Folder to /media/pdf/{month}, the PDF files will be stored on the /media/pdf/2 folder in February and on the /media/pdf/3 in March.

PDF Filename Prefix

Optionally, you can set a custom filename for the generated PDF files. Keep in mind that a random hash will always be appended to the filename. For instance, if you set it to invoice the final PDF filename will become invoice_HASH.pdf, invoice_HASH.pdf e.t.c. You can use Smart Tags to customize the filename prefix.

Paper Size

Select the PDF paper size. This changes the size of the PDF file. The available options are:

  • Letter
  • Half Letter
  • Legal
  • Ledger
  • Tabloid
  • Executive
  • A0
  • A1
  • A2
  • A3
  • A4
  • A5
  • A6

Orientation

Select the orientation of the PDF file. Whether it will be in portrait mode (default) or in landscape mode.

Delete PDF files after

This option helps you automatically deleted old PDFs from your server. To learn more details about this option see the Automatically delete PDFs after X days section.

Attach a PDF copy to Email Notification

A very common scenario is when you want to send a PDF copy of the form submission via email. By using one simple shortcode you can include the generated PDF file as an attachment or as a typical link in the Email Notifications you’ve set up to be sent every time the form is submitted.

Emails that include PDF attachments may be blocked and marked as unsafe by virus scanners. Read more

The shortcode you need to use is the {submission.pdf} Smart Tag which returns the absolute URL of the PDF file stored on your server.

To send PDF as an attachment, edit your form, go to Behavior -> Email Notification and set the Attachments option value to {submission.pdf}.

You can also include a typical link in the email message that points to the generated PDF. To do so, while you’re in the Email Notification section, add the following HTML to Message option:

<a href="/{submission.pdf}">Download PDF</a>

You can also embed the signature as an image with a custom size using the following HTML code:

<img src="/{field.FIELD_NAME}" width="200" />

Replace FIELD_NAME with your Signature Field Name value.

Display a download link to the PDF in the Thank you Message

An alternative and more direct way to present a link to the PDF file is the "Thank You Message" which is dynamically displayed once the form is submitted. In that way, the user who submits the form will be able to access the PDF right away. No page reloads or redirections.

To create a link that points to the PDF file, you must use the {submission.pdf} Smart Tag in the anchor’s HREF attribute like in the example below:

<a href="/{submission.pdf}" download>Download PDF</a>

The download attribute tells the browser to download the file instead of navigating to the link.

View and download PDFs via the administrator

The generated PDF files can also be accessed via the Convert Forms Submission Edit Page in the backend. When a submission has a PDF file available, you will be able to see the path where the PDF is stored in the server and 2 buttons to view and download the PDF as shown in the picture below.

Create a PDF template to be used across different forms

In case you have multiple forms that generate the same PDF template and you find yourself repeating small changes on every form, stop! There’s a solution.

Instead of repeating the same PDF template on multiple forms, you can create the PDF template using a Custom Module and then load the Module using the {loadmoduleid XX} shortcode in the PDF Template option. Where XX is the module’s ID.

To be able to use the {loadmoduleid XXX} syntax make sure the Content - Load Modules plugin is enabled.

Automatically delete PDFs after X days

Convert Forms enables you to delete old PDF files and free up space on your server.

Let’s say you want to automatically delete generated PDF files older than 7 days. To do so, edit your form, go to Behavior -> PDF Form Submission and set the Delete PDF files after option to 7 as shown in the picture below.

There's one more step. You will need to create a CRON job on your server that will schedule the deletion of the PDF files at regular intervals and automate the process for all forms that generate PDFs. This CRON job must be created once per site. So, if you have already set it up, skip this step.

Below you can find the command you will need to add to your host's CRON interface:

wget "https://www.yoursite.com?option=com_convertforms&task=cron&command=cleanexpiredpdf&secret=SECRET_KEY”

Replace https://www.yoursite.com with your site’s full URL and SECRET_KEY with the secret key you've set in the Convert Forms configuration page.

Frequently Asked Questions

What are the requirements to use the PDF Form Submission addon?

Below you can find the requirements your server and your Joomla site needs to meet in order for the PDF Form Submissions to work.

  • Convert Forms Pro 2.6.0
  • PHP 5.6 (PHP 7.1+ Recommended)
  • DOM PHP extension
  • MBString PHP extension

If you are using SVG images in your PDFs you will need to install the PHP library called php-svg-lib.

Can I create PDFs conditionally?

No. Conditional Logic is on the roadmap it will be supported in a future release.

Can I protect PDF with a password?

No. This is on the todo-list and it will be implemented in a future release.

Can I add a new page in the generated PDF?

To add a new page in your PDF, you will need to add the following HTML in your PDF Template > Source Code just before your next page begins.

<div style="page-break-before: always;"> </div>

Can I change the font?

Changing the font family isn't currently supported.

Can I customize the PDF message?

To customize the PDF message, including the font size and color, you can do so within the form > Behavior > PDF Submissions > PDF Template text editor. The text editor allows you to format the text that appears within the PDF.

Can I include the submission ID In the file name?

Convert Forms now appends a random hash at the PDF file name for privacy reasons, instead of adding the submission ID as it previously was. However, you can still revert this change and include just the submission ID.

Troubleshooting

Emails are blocked and marked as unsafe by virus scanners

If you're attaching the generated PDF in an auto-responder email, the email may be blocked and flagged as malware or unsafe by the recipient's mail server with one of the following errors.

  • HEUR:Exploit.pdf.Generic
  • 550 "The mail server detected your message as spam and has prevented delivery."
  • 550 Message contained unsafe content (Sanesecurity.Malware.27423.PdfHeur)

This is false-positive and it only happens when the PDF file is included as attachment in the email and the PDF file contains hyperlinks with <a> tags.

The PDF Form Submissions addon is based on the domPDF PHP library to convert HTML into PDF and this is a well-known issue in the community.

Although there's no solid fix yet, here are some workarounds that will help resolve the issue to some degree:

  • Inlcude the generated PDF as a link in the email message instead of attaching as a file.
  • Disable PDF compression. Edit the file plugins/convertformstools/pdf/helper/pdfhelper.php and replace line 117 $output = $dompdf->output(); with $output = $dompdf->output(['compress' => 0]);
  • Remove all <a> tags from the PDF Template. Most of the PDF viewers will still treat your URLs as hyperlinks.
Last updated on Oct 29th 2024 14:10