Calculated Fields Form Blog

Tips and cases of use for a successful WordPress website with calculated forms.

Blog / Generating PDF files at runtime with the information collected by the form

Generating PDF files at runtime with the information collected by the form

Integrating the form with the WebMerge service to generate PDF files at runtime with the information collected by the forms. The post describe a case of use: the generation of purchase invoices.


The Calculated Fields Form plugin it is not able to generate PDF files at runtime by itself, however, the Platinum version of the plugin is distributed with the WebMerge add-on to supply this functionality.

The WebMerge add-on allows the integration between the form with the WebMerge service. WebMerge can create PDFs and other printable documents (like Word, PowerPoint, etc.) on the fly with data submitted by the form to create printable event tickets, online applications, invoices, and much more.

I'll describe the process with a case of use: Create a form for selling a product, and generate an invoice on the fly to be sent the buyer.

The first step in the process would be design the document template in WebMerge:

Login in WebMerge and click on the button: "New Document":

Create a new document template

Enter the name of new document template:

Template name

Choose the document type. In this case I'll select the "Build Your Own" option to have the total control over the template's structure:

Document type

Create the template's structure as you need. WebMerge includes a WYSWG editor that facilitates the editing process. In WebMerge the texts with the format: {$varname} represent the fields that would be replaced by the final texts when the PDF file is generated:

Template text

As you can see, the previous template includes the fields:

firstname lastname address email date number item_description quantity and price

Select the file to generate from the settings tab, in my case the PDF option:

Output file

The next step shows all available variables and allows you generate PDF files for testing the template. I simply will press the "Skip to Next Step" button:

Test template step

Configure the delivery option. I'll send the generated files to an email address received as a WebMerge field, in this case, to the value received in the "email" field:

Delivery option

The last step displays the "Merge URL", copy this URL because would be used to integrate the form with the WebMerge service:

Merge URL

After create the document on WebMerge is time to implement the form in the website, and integrate the form with WebMerge:

Go to the settings page of the plugin through the menu option: "Settings > Calculated Fields Form", tick the "CFF - WebMerge" checkbox and press the "Activate/Deactivate Addons" button:

Activate the add-on

Implements the form as usual, inserting the fields that would be sent to WebMerge to generate the PDF file:

Form fields

Scroll down in the form settings until the WebMerge section, and press the "Add New Document" button. Paste the URL copied previously from WebMerge, into the attribute: "Document URL". Press the "Add Field" button as many times as WebMerge's fields need to be integrated with the fields in the form.

The WebMerge fields are entered at left, and the corresponding form's fields at right. There are some fields that are integrated to other constants that are not fields in the form: itemnumber corresponds to the submission's id, submissiondate_mmddyyyy corresponds to a date/time text with the submission's date. If the value entered is not a field's name, or any of previous constants, it will be considered a plain text, like Appointment Hour Booking:

WebMerge Section

Insert the form in the public website for testing:

Public Form

The generated PDF file with the fields replaced by the corresponding values submitted from the form:

PDF File

That's all, I've created a document template in WebMerge, implemented a form in the website, and integrated both. Finally, I've tested the form and generated the PDF file.