The Form.io PDF Solution is a powerful tool with two options: PDF Server and PDF Server Plus. Please see the below description of each to see which aligns best with the requirements of the Application being built.
The Use Case: Starting with dynamic, JSON-driven, responsive webforms that users are filling out and submitting within an application, I want to print out a PDF of the web form submission.
The Use Case: Forms are required to be on a pixel-perfect PDF background with a dynamic JSON form overlay on top of the PDF.
PDF-First forms can also be presented to the user as responsive web forms, but enable the ability to print the Submission to the pixel-perfect PDF background.
Recommended CPU/memory config is 2 CPU cores and 4GB of memory.
A common deployment command for the PDF server looks as follows.
docker run -itd \
-e "LICENSE_KEY=YOURLICENSE" \
-e "MONGO=mongodb://mongo:27017/formio" \
-e "FORMIO_S3_SERVER=minio" \
-e "FORMIO_S3_PORT=9000" \
-e "FORMIO_S3_BUCKET=formio" \
-e "FORMIO_S3_KEY=CHANGEME" \
-e "FORMIO_S3_SECRET=CHANGEME" \
--network formio \
--link formio-mongo:mongo \
--link formio-minio:minio \
--restart unless-stopped \
--name pdf-server \
-p 4005:4005 \
Which uses the following Environment Variables.
A Form.io license key
Mongo connection string, same as formio-enterprise setting.
Set this environment variable to communicate server-to-server with the PDF Server. The value for this enviornment variable is used along with the
The DB Secret, same as formio-enterprise setting.
Mongo database name, if using localhost
File path to an SSL certificate authority file. This is usually a file with an extension of ".pem". For example, AWS DocumentDB may require this to be like the following value: "/src/certs/rds-combined-ca-bundle.pem"
Whether to enable using docker secrets.
The path to the docker secrets.
URL to a version of the pdf viewer application
S3 server URL
S3 server port
S3 server bucket name
S3 access key
S3 secret key
Azure Blob connection string
Azure Blob container name
Boolean to indicate if the license key provided is an offline remote license key.
Determines how long (in milliseconds) the browser can run and execute before timing out. Default is 120000 milliseconds or 2 minutes.
Perform debugging within a PDF server. The following debug commands will do the following. This uses the Debug Module for Node.js so documentation can be found @ https://github.com/visionmedia/debug.
Now that you have the PDF server operational as well as the API Server, the next thing that needs to happen is to configure the Form.io Portal to use the correct DNS url for the PDF Server url. This is necessary because the "internal" DNS url is used within the Enterprise Server configurations, and we now need to let the Portal know how to directly communicate to the PDF Server. To set this up, you will first need to navigate to your Project Settings, and then click on PDF Server configuration page. Here you will then need to provide the Public DNS url to the pdf server as follows.
Configure the Public DNS url to the PDF server in your project settings.
Once you have done this, you should now be able to upload an existing PDF form, where it will then convert that PDF document into a Form.io webform overlay on top of that PDF form.
This section covers some aspects of fine tuning PDF server. If you want to speed up your deployment or you want to configure your deployment for large PDFs handling, you might want to give a look at this section.
If you have a virtual machine with large amount of RAM available, you can benefit from it by mounting container's
/tmpdirectory to RAM. You can to this by adding
--tmpfs /tmp:rwparameter to your
docker runcommand. This will allow PDF Server to speed up IO processes by storing files in RAM instead of disk.
File cache is a disk cache for HTML files used for PDF downloads. Default cache time is one hour. If you have a lot of PDF first forms with different PDFs in the background and you expect that all that forms will be printed to PDF very often, you might want to configure file cache time to eliminate disk memory limit reach. To do this you need to add
FILE_CACHE_TIMEenvironment variable to PDF Server config. The value should be number of milliseconds. The smaller cache time will result to less disk space usage and lower performance. The bigger cache time will result to more disk space usage and increased performance.
If you prefer to use custom viewer rather that default viewer for PDF downloads, you can increase PDF download performance by adding
PAGE_POOL_DEFAULT_VIEWERenvironment variable to PDF server config. Its value should be the URL of your custom viewer.
Here is the list of all configurable timeouts and the their purposes:
Used for PDF downloads. If you are printing large PDF files or your custom viewer has a lot of contents, you might want to increase this value.
Used for PDF downloads. If you are printing large submissions and/or large PDF files, consider increasing this value.
Primary timeout for html generation. It's used for PDF uploads. If you are going to upload large PDF files, consider increasing this value.
Backoff timeout for html generation. Its sum with primary timeout will be used for second try after postscript optimisation in case when first try failed. If you are going to upload large PDF files, consider increasing this value as well.
The PDF Server Plus includes Auto-Conversion of existing fillable and non-fillable PDF Forms. Using AWS Textract for PDF First Forms that do not have any metadata that can be read for conversion, the PDF Server will auto-detect Field Input Types, Labels and more and convert the PDF to a dynamic Form.io Form!
After setting up PDF Server it is possible to integrate with AWS Textract to enable Formfields Recognition feature.
- 1.Create IAM role with policies:
Save ARN, it will be used later.
- 2.Create AWS Simple Notification Service topic and save its ARN
- 3.Add the following environment variables to configuration:
ARN of IAM role for Textract.
ARN of SNS topic.
S3 bucket folder where Textract will store its output.
4. After starting PDF environment with new environment variables, go to previously created SNS topic page and create a subscription:
- Left topic ARN as it is
- In Protocol field choose HTTP
- In Endpoint field type *public URL of your environment*/pdf/pdf/sns
In case of misconfiguration, you will not be able to upload a PDF file.
5. After configuration you can check the status of formfields recognition by visiting URL