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 in Docmosis, using 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 to Docmosis and initiate the document generation.

When the form is submitted, an HTTPS Connector sends the data to the Docmosis Cloud service. The Cloud service merges the data with a Microsoft Word template to generate and email a PDF letter, like this one:

Follow the steps below, if you would like to try out this example.

You will need

A Docmosis Cloud account

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

Once you have an account, log in to the Docmosis Cloud Console using your email and password.

Note: In this example, we used the US 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.

A FormAssembly account

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

Step 1: Prepare Docmosis for generating the document

To prepare, you need to upload the sample template we provide on this page to the Docmosis Cloud service, and also get the API access details for your Docmosis Cloud account.

1.1 Download the provided sample template

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

The provided template is designed for this exercise. The placeholders in the template will be replaced by data from FormAssembly, when Docmosis generates the document.

  • Click on the image or link below, to download the provided template, called LetterTemplate.docx.

 

Download the template

Note: The LetterTemplate.docx template is ready to use, without any further changes. 

1.2 Upload the template to Docmosis

Upload the LetterTemplate.docx template to the Docmosis Cloud, so that it can be used to generate a document from, when the form is submitted.

  •  If you are not already logged in to the Docmosis Cloud, log in using your email and password.

The default processing location for the account is selected. Pictured below, the default processing location for the logged-in user is US (Oregon).

  • Click  New Folder in the Templates tab, to create a new top-level folder for the LetterTemplate.docx template.

  • Name the new folder FormAssembly, then click Create.

  • Now click on the new FormAssembly folder to open it.

  • Click Upload Template, then select the LetterTemplate.docx template to upload it.

The template is uploaded to the selected FormAssembly folder. 

1.3 Get the Docmosis Cloud Access Key and the API URL

Copy your Cloud Access Key and the API URL for your processing location and paste these into a text editor, such as Notepad. These will be required later, when you set up a FormAssembly connector for posting your data from FormAssembly to Docmosis.

  1. Select Account from the left menu bar.
  2. Copy the URL for your selected region, US (Oregon) in this example, and paste it into Notepad.
  3. Click Show Access Key. Now copy the Access Key and paste it into Notepad.

Step 2: Prepare FormAssembly

In FormAssembly, create a form to collect data, and add a connector to send the data and call the Render service on Docmosis.

2.1 Build a new form in FormAssembly

In this example, the “Apply for a Position” FormAssembly template is used to create the form as most of the fields are a close match for the LetterTemplate.docx template data requirements.

  • Log in to your FormAssembly account, using your username or email, and password.

Create a new form using the “Apply for a Position” FormAssembly template.

  • In FormAssembly, select TemplateLibrary from the side menu, then filter on the Human Resources (HR) category.
  • Click Use on the Apply for a Position template.

The new form opens in Build mode.

  • Add content to the form, if additional input fields are required, and format the fields if necessary.
  • Click Save to save the form.

In this example, there is a new title, and the "Name", "E-mail", and "Position applying for" fields are set as required.

2.2 Add a connector to the form in FormAssembly

Add an HTTPS connector to call the Docmosis Render service with instructions and data, immediately after data is captured and submitted in the form.

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

  • Choose HTTPS to securely send data to another website or app (this will be Docmosis).

2.3 Configure and enable the connector in FormAssembly

In the connector, map the form field names to the Docmosis template field names, and add extra custom fields, not supplied from the form fields, for the remaining Docmosis template field names.

Then add the Docmosis Render request parameters and values for the accessKey, templateName, outputName, outputFormat, mailTo: and mailSubject: as custom fields. This is to instruct Docmosis which template to use, what the output name and type should be, and where to send the document. 

  • Click Configure, to configure and enable the connector.

  1. Update the connector description: click on the description to edit it.
  2. Update the status to Enabled.
  3. Add the Remote Script details: paste in the Docmosis URL for your processing location, and append with "renderForm". Keep the POST (default) HTTP request method.

  • Edit the field names so that they match the names in the Docmosis template. Note: these are case sensitive.

Note: Only some of the fields are used in the Docmosis template, and can be removed from the connector.

  • Add custom fields that are not provided in the form template, for the Docmosis Render request parameters: 
    In this example:
accessKey Paste in the access key for your Docmosis account Copied to Notepad in earlier step
templateName The folder name and template name in Docmosis /FormAssembly/LetterTemplate.docx
outputName The name for the rendered document Use the formula f option to build up a file name that includes the applicant name
outputFormat The format of the rendered document PDF
storeTo: Specify where to send the document mailto:This email address is being protected from spambots. You need JavaScript enabled to view it.
mailSubject: Specify a subject line, if the mailto: option was used. Use the formula option to build up a subject line that includes the applicant name 

 Note: the mailto: email address is the same one used for the Login on your Docmosis trial account. 

  • Add fields for values that will be used in the LetterTemplate.docx template. 
Field Name Value
acknowledgedate Use the formula option to get the current local date.
hrRep.Name The name of your HR representative
hrRep.Title The title of your HR representative
  • Save the connector.

After the connector is saved, it is ready to test.

Step 3: Generate a document using the form

The new form is ready to try out. Capture and submit data from your new FormAssembly form, and then check your email inbox for the generated PDF letter.

The data in the letter should match the data captured in the form, and also the Additional values from the connector, as shown below:

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

 

  • Fill in the form details, then click Submit.

The connector posts the form data and other details to Docmosis, and Docmosis generates a PDF using the supplied data and the specified template (LetterTemplate.docx), then sends the document as an attachment to the supplied email address. 

  • Open the email and the generated PDF in the attachment.

The generated PDF contains the fields sent by the FormAssembly connector.

Download PDF

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

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