Generate a PDF document from FormAssembly

With FormAssembly you can easily create web forms and send data to other services, such as Docmosis.

This article explains how to generate a PDF document using Docmosis with data captured in a FormAssembly form.

Overview

In this example we show you how to create a simple FormAssembly web form to collect data, and how to send this data to Docmosis and initiate the document generation.

We make use of a FormAssembly feature called "HTTPS Connector" to send the data to the Docmosis Cloud service, each time the form is submitted. The Cloud service merges the data with a Microsoft Word template to generate a PDF letter, like this one:

You will need

FormAssembly account

If you don't have a FormAssembly account, start a trial here

Docmosis Cloud account

If you don't already have a Cloud account, you can sign up for a free trial here.

Once you have an account, log in to the Cloud Console.

Set up FormAssembly and Docmosis for document generation

Step 1: Upload the sample template

Docmosis templates are ordinary Microsoft Word documents, with special placeholders that Docmosis replaces with data when it generates the document. 

1.A) Create a new top-level folder in Docmosis for storing the sample template. In our example, we have named the new folder FormAssembly.

1.B) Click on the image or link below, to download the sample template: LetterTemplate.docx.

 

Download the template

The LetterTemplate.docx template is ready to use, without any further changes. You can see the placeholders in the template, below.

1.C) Upload the LetterTemplate.docx template to the new FormAssembly folder in the Cloud console.

Step 2: Get the Docmosis Cloud access key and API URL

You will need your access key and URL when setting up the call to Docmosis in your FormAssembly HTTPS connector. Copy these to an editor such as Notepad, to be used later.

Note: In this example, we used the US (Oregon) processing location in the Docmosis Cloud service, for storing the template and generating the document. You can use your default processing location, when following this example.

Step 3: Build a new form in FormAssembly

In FormAssembly, we will pick a form from the template library. This form will be used to collect the data that will be sent to Docmosis.

3.A) Log in to FormAssembly.

3.B) Create a new “Apply for a Position” form.

  • Select TemplateLibrary from the side menu.
  • Filter on the Human Resources (HR) category.
  • Click Use on the Apply for a Position template.

Note: The “Apply for a Position” form was chosen for this example, as most of the fields are a close match for the LetterTemplate.docx placeholders.

3.C) In the Build tab, adjust the new form, then click Save to save any changes.

You can add content to the form, if additional input fields are required, and format the fields if necessary (this includes setting a field as required).

In this example, the Title is updated to "Apply for a Position at Meta Legal and Finance" and the fields "Name", "E-mail", and "Position applying for" are set as required.

Step 4: Add an HTTPS connector to the form in FormAssembly

Add an HTTPS connector to securely send data to "another website or app" after a form is submitted.

4.A) Click on Connectors in the side menu, then click on Add connector for after form submission.

4.B) Choose HTTPS to securely send submitted data to another website or app.

Step 5: Configure the FormAssembly connector to call the Docmosis Cloud API

5.A) Click Configure to edit the connector.

  • Optionally update the connector's description. We used "Docmosis to render personalized letter of receipt.".
  • Select Enabled for STATUS.
  • Paste the Docmosis base URL for your processing location into the REMOTE SCRIPT URL edit box.
  • Append the base URL with "renderForm" in the REMOTE SCRIPT URL edit box. 
  • Select POST (default) as the HTTP REQUEST METHOD.

Step 6: Map the form fields to the Docmosis placeholders

In the connector, type in the Docmosis placeholders corresponding to each form field. The Docmosis placeholders are case sensitive.

Note: Only some of the form fields are needed as placeholders. Others may be removed from the connector.

Step 7: Add custom fields to the connector

Additional values are required that are not supplied in the form.

7.A) Click Add another custom field to add each of these additional values:  

Additional values(in this example) Field Name Details
ZWNkZGY1NjEtOTQ4OC00MmN......... accessKey Paste in the access key for your Docmosis account
/FormAssembly/LetterTemplate.docx templateName The folder name and template name in Docmosis
Application_from_%%tfa_2%%tfa_3%% outputName Use the formula f option to build up a file name that includes the applicant name
PDF outputFormat This is the format of the rendered document
mailto:This email address is being protected from spambots. You need JavaScript enabled to view it. storeTo: Your email address.  Used for delivery of the generated document.
Application_from_%%tfa_2%%tfa_3%% mailSubject: Use the formula option to build up a subject line that includes the applicant name 

Note: the mailto: email address must be the same one used to Login to your Docmosis Cloud account. If you are on a free trial, you are restricted to only sending emails to yourself. To remove this limitation, on paid accounts, please contact Support.

7.B)  Click Add another custom field to add each of these additional values for placeholders:

Additional values (in this example) Field Name Details
@LOCALTODAY() acknowledgedate Use the formula f option for the local current date
Julie Partner hrRep.Name Type in a constant value (your own value)
Human Resources Manager hrRep.Title Type in a constant value (your own value)

7.C) Click Save to save the changes to the connector.

This concludes the steps for setting up the integration between FormAssembly and Docmosis.

Try out the new integration

Your new integration is ready to try out. 

Step 1: View the form

In FormAssembly, click View in the side menu to view the form.

 

Step 2: Submit the completed form

Enter the values in the form, then Submit.

The connector sends the data to the Docmosis Cloud service. The service merges the data with LetterTemplate.docx to generate a PDF document.

The generated document will be sent via email, with the document as an attachment, to the email address that was supplied for the storeTo: field in Step 7.A. 

Step 3: Check the email

3.A) Check your inbox for an email from Docmosis Web Services.

 

3. B) Open the email and the generated PDF in the attachment.

3.C) The PDF below is the one we created in our example. You can download it by clicking the image or the link.

Download PDF 

The PDF letter contains the data captured in the form, and also some of the Custom fields from the connector, as shown below:

Troubleshooting

If you do not get the expected results, read the message in the Connector log in FormAssembly to troubleshoot the issue.

To view the response message from Docmosis, click Show received data for a log.

Below is an example of a response message for a call that failed.

Feedback

Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input

Applies To

Docmosis-Java Tornado Cloud
Version(s) - - DWS3