Pdf Fill Form Fields

Content Type: Module
Categories: Import/Export

Overview

This module contains Java Actions to read, fill or update form fields in a pdf file. 

These form fields can be of type text or checkbox (choices in pdf forms are checkboxes as well). 

Also when a form field is as a read-only field, this Mendix module can still update the field value.

A new feature to flatten the form fields, meaning the fields are converted to normal pdf content, has been added. This means that after flattening there are no fields any more, as it has been converted to normal text. This means that the values cannot be read or updated any more.

Use case examples: 

  • Generating pdf documents from your pre-defined pdf templates by filling the fields with the actual data. For example business proposals, invoices, delivery notes, licenses, bills, tickets, diploma's, etc. You can also convert the document to plain pdf, so end users with outdated pdf software can read it (see the form field content) as well;
  • Automatically (pre) filling pdf form documents with data from Mendix; 
  • Automatically validating and processing contract and client data in Mendix by reading the data out of your pdf forms that your clients have completed (and uploaded or send to you by email). Tip: use a (hidden) read-only field with a random generated number (GUID) and save that in the Mendix app to validate if this form was send to, and thus is valid for, the specific user. 

Documentation

Demo urlhttps://tspdfeditormaintenanceproject100-sandbox.mxapps.io/

Functionality

This module contains Java Actions to read, fill in or update a pdf file containing form fields. 

These form fields can be of type text or checkbox. (choices in pdf forms are checkboxes as well). 

The Java Action to fill in the fields is JA_UpdateFields.

There is also the Java Action JA_GetFields to retrieve the name of all the fields as well as the current values. The field name is needed when you want to implement filling in (updating) a field in the Mendix microflow.

A new feature has been added, “JA_FlattenForm. This can be used to convert the form fields to normal ‘plain old’ pdf content. After doing this, there are no form fields any more, so the values can not be updated or read by this module.

This can be useful for end users with outdated pdf software that doesn't render (display) the value of form fields. 

The java action JA_UpdateFields had been updated with an extra param (boolean flattenForm), so these actions can be combined (first update fields, then flatten form).

Pdf form fields can be created and edited with the official Adobe Pdf editor.

Tip: When you do not want your end users to be able to update/change certain (or all) fields, you can set these fields as read only fields in the Adobe Pdf editor.  This will not affect this module to be able to change/update these fields.

 

Demo

https://tspdfeditormaintenanceproject100-sandbox.mxapps.io/

 

Domain Model

The domain model contains several supporting entities.

Only two of them are persistent, so they can be stored when necessary: Field and PossibleValue.

The entity Field contains the field definition, which is the output of JA_GetField and JA_GetFields. 

Storing this information enables you to associate a field definition with an entity of your own domain model.

This is not needed, so only do this when it is required for your specific functionality.

Tip: you can extend this Field entity when you want to store more information (e.g. page number where the field is located).

 

 

IDE Integration

The module integrates with the Mendix Studio Pro IDE, so these Java Actions appear in the Toolbox menu under the new group "Pdf Form Editor". They can be dragged and dropped in a Microflow and are graphical represented by their own pdf icon.

 

 

Problems

Be aware that when there is logic inside the pdf (javascript), this logic can interfere with the fields you want to fill in by Mendix, especially when this javascript disables or enables fields, changes field values or empties fields.

The solution is to strip off this logic, so remove the javascript, from the pdf. You can easily do this with the licensed version of the Adobe Pdf Editor.

 

 

Dependencies

These Java Actions in Mendix use custom java which is located in a java archive, a jar file:

  • pdfeditor version 1.1.0

This jar needs other jar files (dependencies):

  • commons-logging
  • pdfbox
  • fontbox

These are jar files are included in the module:

A migration file has been added to support for Gradle dependency management in Studio Pro version 10.3.0 and later.

From version 2.0.0 of this module, newer versions of these jars are automatically retrieved with the Gradle jar dependency functionality in Studio Pro, because a version range is set.

Hint: When you do not want to update or commit newer version each time, you can either disable Gradle synchronization in Studio Pro or you can set a fixed version for these jars in your own main module in your project. You can consider to use a dedicated empty module for this and give it a meaningful name

(eg. GradleDependencyModule).

 

Upgrading from version 1.0.1 to higher:

When upgrading from the previous versions, do not forget to remove the dependencies (jar files) of the previous version from the userlib folder.

Also the new parameter, boolean flattenForm, has to be set when the Java Action "JA_UpdateFields" is used.

 

Screenshot Descriptions

Descriptions of the screenshots below this section:

  1. The domain model in Mendix Studio Pro
  2. Example of usage in a microflow in Mendix Studio Pro
  3. Pdf Form Editor integration in the Toolbox of Mendix Studio Pro
  4. Example of usage: pdf of the Dutch tax authorities with form fields which are filled by a Mendix application, so a new tax document is generated fully automatically.

Releases

Version: 3.0.0
Framework Version: 10.21.0
Release Notes: Updated to Studio Pro version 10.21.0.
Version: 2.0.0
Framework Version: 10.12.0
Release Notes: Upgraded to Studio Pro version 10.12.0
Version: 1.2.0
Framework Version: 9.18.0
Release Notes: Updated jar files and added migration file. This version depends on the following jars (all included in the module): pdfeditor-1.1.0.jar commons-logging-1.3.0.jar fontbox-2.0.30.jar pdfbox-2.0.30.jar Developers: Rik Bos, Emiel Paasschens
Version: 1.1.0
Framework Version: 8.12.3
Release Notes: Release Notes New version of the PdfFormEditor with the addition feature 'Flatten Form' . This module has been uploaded to the Store as "Pdf Fill Form Fields" because that name better describes its functionality. This version depends on the following jars (all included in the module): pdfeditor-1.1.0.jar commons-logging-1.2.jar fontbox-2.0.26.jar pdfbox-2.0.26.jar Developers: Rik Bos, Emiel Paasschens
Version: 1.0.1
Framework Version: 8.12.3
Release Notes: Bugfix version of first release of the PdfFormEditor module by TimeSeries. This module has been uploaded to the Store as "Pdf Fill Form Fields" because that name better describes its functionality. This version is dependent on the following jars (all included in the module): pdfeditor-1.0.1.jar commons-logging-1.2.jar fontbox-2.0.22.jar pdfbox-2.0.22.jar Developers: Rik Bos, Emiel Paasschens