PDF as mail attachment

PDF attachment options

Note: These features are part of the Visforms Subscription and are not included in the free Visforms version.

For a better understanding, we recommend reading the documentation completely and using the Section Introduction to start.
Relationships explained in earlier sections of the documentation are not repeated here.

You have the following PDF attachment options:

  • Generate PDF of the result mail and attach it to the result mail.
  • Generate PDF of user mail and attach to result mail.
  • Generate PDF of user mail and attach to user mail.
  • Generate an individual PDF of the transmitted data and attach it to the result mail.
  • Generate an individual PDF of the transmitted data and attach it to the user mail.

Note: Emails are only generated and sent if the "Send mail" option is activated for the corresponding email type in the "Email options" tab of the form configuration. The corresponding email types are result mail and user mail.

Options for the result mail

PDF Attachment Options

You can attach the following to the result mail, which is usually sent to the website operator:

  • the PDF of the user mail,
  • the PDF of the result mail and
  • an individual PDF document.

Simply set the corresponding option to “yes”. Or, for an individual PDF document, select the appropriate PDF template. You must have created the PDF template beforehand. More on this in: Create PDF documents.

User mail options

PDF Attachment Options

You can attach the following to the user mail:

  • the PDF of the user mail and
  • an individual PDF document.

Simply set the corresponding option to “yes”. Or, for an individual PDF document, select the appropriate PDF template. You must have created the PDF template beforehand. More on this in: Create PDF documents.

All PDF files are created temporarily. After the emails have been sent successfully, the temporary PDF files are automatically deleted again.

Possibilities and limits of PDF export

Visforms generates HTML mails, i.e. the content of the result mail and the mail to the user are generated as HTML by Visforms. In order to generate a PDF from the mail content, this HTML must be converted into PDF. This is necessary because PDF and HTML are completely different formats. To do this, Visforms uses the widely used open source PHP library “TCPDF”. Many other components that offer PDF creation also use this PHP library “TCPDF”.

This library contains a simple parser that translates HTML into PDF format. In a modern browser or email client, the HTML and the CSS specifications are largely fully supported.

In contrast, TCPDF supports a limited subset of HTML tags and a very limited set of CSS specifications. In particular, the following CSS properties are not supported by this parser, such as

  • margin,
  • padding or
  • float.

You should therefore refrain from such “advanced” formatting when creating the email if it is also to be used as a PDF attachment. Unfortunately, this quite common HTML formatting later in the PDF does not lead to the desired result.

With regard to the text content, however, emails and PDFs should be completely identical.

Customize the file name of the PDF file

Visforms uses a default name under which the PDFs are attached to the mails. This file name is generated using a language code. The file name can therefore also be adjusted using the Joomla feature “Language Override”. The changed name will then be used for all mail attachments.

Name of result mail PDF

The file name of the result mail PDF is determined by the following translation rule:
PLG_VISFORMS_VFMAILATTACHMENTS_RESULT=”%s-result mail".

Where %s is a placeholder that will be replaced with the form name. If you want to adapt the file name of the result email PDF, you must store a different translation for the language key PLG_VISFORMS_VFMAILATTACHMENTS_RESULT.

Name of the user mail PDF

The user mail PDF filename is determined by the following translation rule:
PLG_VISFORMS_VFMAILATTACHMENTS_RECEIPT=”%s-usermail".

Where %s is a placeholder that will be replaced with the form name. If you want to adapt the file name of the result email PDF, you must store a different translation for the language key PLG_VISFORMS_VFMAILATTACHMENTS_RECEIPT.

Create override

Customize PDF file name

Run the following:

  • In your website administration go to Extensions » Languages » Overrides
  • Under “Filter” on the left, select your language and site (non-admin).
    Do not select “Administrator”, see red arrow.
  • Click on the “New” button.
Language Override

Run the following:

  • Enter PLG_VISFORMS_VFMAILATTACHMENTS_RESULT or PLG_VISFORMS_VFMAILATTACHMENTS_RECEIPT in “Language key”, depending on which file name you want to change.
  • Enter the desired file name under “Text”.
    If you want to keep the form name in the file name, you can use the placeholder %s.
    If you want to store a fixed name, then simply write this name in the “Text” field.
  • Click “Save & Close”.
  • If necessary, repeat the process for the name of the other mail type.

Examples

Form nameTextFile name
form1%s-usermailform1-usermail.pdf
form1mynamemyname.pdf
form2other-name%sother-nameform2.pdf