Plugin - PDF (Attach an automatically generated PDF to an email)

Based on the PHP dompdf library, the RSform!Pro PDF plugin is designed to generate PDF files that include submission information. The PDF files can then be attached to the built-in User and Admin emails or accessed via special placeholders.

RSform!Pro PDF plugin video tutorial:

Minimum requirements (same as dompdf requirements)

  • PHP 5.0+ (5.3 recommended)
  • MBString extension
  • DOM extension

Please check with your hosting provider first if you meet the minimum requirements.

The plugin can be installed via the usual Joomla! installer. You can read more on this process here.

Once the plugin has been installed and published, the following configuration parameters are available within the Components > RSForm!Pro > Configuration > PDF area:

  • Font: the font type that will be used to generate the PDF files
  • Orientation: sheet orientation - portrait / landscape
  • Paper Size: the paper format, e.g. A4

Note:

Some special chars are not supported by all PDF font types. For example if your submissions or PDF text will be in Chinese, you will need to use the special, Firefly font. For languages that use UTF-8 chars, you can use the DejaVu Sans. Both font files are available for download within the My downloads > RSform!Pro > View all plugins and modules > RSform!Pro files > 3rd Party area.

To install additional fonts, simply upload them (using a FTP client) within the administrator/components/com_rsform/helpers/pdf/dompdf8/lib/fonts/ folder. Once the files have been added to the proper location, you will be able to select the desired font within the RSForm!Pro > Configuration > PDF area. Please note that this is only available for the fonts downloaded from our website, to install fonts obtained from any other source, please consult the dompdf documentation.

 

PDF layout and content configuration

Accessing the User / Admin email configuration areas will reveal the PDF configuration area. Simple configuration options are available:

  • Attach to email: if enabled, the generated PDF file will be attached to the User / Admin email.
  • File name: the name of the generated file.
  • PDF Layout: allows you to specify the actual content and layout of the generated PDF file. You can use use standard HTML along with the usual RSform!Pro placeholders (listed by clicking on the Toggle Quick Add button)
  • User Password (optional): Set a password that you can pass on to your users. The options selected in the Allowed Options field (explained below) will be applied for users who view the file using this password.
  • Owner Password (optional): Set a password that you can keep for yourself or other administrators. When logging in with this password, you will have complete freedom in editing the PDF file.
  • Allowed Options: Print the document / Modify the document / Extract contents (copy) / Comment in the document - Use CTRL + Click to select the permissions that you wish to associate the generated PDF file with. These will be applied for users who view the file using the User Password and even if no passwords are set for the file.
Note:

Limited CSS control is also provided. You can read more on the dompdf CSS compatibility here.

In order to display images in the PDF you will need to use the exact site path. To simplify this process we have added the {sitepath} placeholder.

Instead of:

 
<img src="http://www.mydomain.com/path/to/images/my-image.jpg" alt="My image" />
 

use:

 
<img src="{sitepath}/path/to/images/my-image.jpg" alt="My image" />
 

Starting with rev. 45, a new placeholder was added, {your_field_name:localpath}. When used, this placeholder will return the local path of the image found on the server (eg. /home/public_html/path/to/uploaded/image.jpg).

Example:

 
<head>
<style type="text/css">
h1 {
 margin:3px auto;
 font-size:18px;
 color:blue;
}
p {
 background:#fefeda;
 text-indent:20px;
 text-align:left;
}
</style>
</head>
<body>
 <h1>Sample content here</h1>
 <p>Dear, {Name:value}, thank you for taking time to submit the form.</p>
 <img src="{sitepath}/images/sample.jpg" width="130" height="80" alt="Sample"/>
</body>
 

The generated PDF files don't necessarily need to be attached to generated emails. These can also be accessed via the {user_pdf} and {admin_pdf} placeholders. You can use them inside the RSform!Pro generated emails, Thank you message, Submissions View menu item (details view) and the Submissions directory area (details view and emails). The above placeholders will return the exact path to the PDF document, you could use them in a general link tag in order to create a link to the PDF file, for example:

This is a link to the <a href="{user_pdf}">User PDF</a> document.

RSForm!Pro takes things further and allows dynamic control over the generated PDFs. Basically, you can use PHP code spinets to control the content of generated PDF. This can be done via the specialized PHP PDF Pre-Processing Scripts area (Components > RSform!Pro > Manage forms > edit a form > Properties, Scripts section), which contains two sections: one for the User email PDF and one for the Admin one.

The following PHP variables can be used for manipulation:

  • $args: array that contains the submitted information.
  • $info: a variable that stores the HTML layout (which will be transformed into a PDF).

Available global placeholders:

  • {global:username} - displays the username
  • {global:userid} - displays the user ID
  • {global:useremail} - displays the email of the user
  • {global:fullname} - will display the Full Name registered for the current user
  • {global:userip} - displays the ip of the user that submitted the data
  • {global:date_added} - displays the date when the form was submitted
  • {global:sitename} - returns the name of your site
  • {global:siteurl} - returns the URL of your site
  • {global:confirmation} - displays the URL used for the submission confirmation
  • {global:confirmed} - displays the status of the submission
  • {global:submission} / {global:submission_id} - returns the ID of the submission

Tip: Adding a page-break

If the size of the PDF exceeds one page, the PDF will automatically display the data on multiple pages. You can have more control over the information displayed on a certain page by using the following syntax:

 
<div style="page-break-after:always">First page data here</div>
 
<div style="page-break-after:always">Second page data here</div>
 
<div style="page-break-after:always">Third page data here</div>
 

40 persons found this article helpful.


Was this article helpful?

Yes No
Sorry about that

You Should Also Read

PHP PDF Pre-Processing Scripts

Improving the PDF export for submissions

Using the {if} statement with RSForm!Pro PDF plugin

PDF plugin - tips and tricks

Save PDF file to folder