Xbasic

pdf_fillInFields_merge Function

Syntax

dim result as L = pdf_fillinFields_merge(pdfFileIn as C, pdfFileOut as C, JSONData as C [, storageConnectionString as C [, s3ObjectName as C]])

Arguments

pdfFileInCharacter

The PDF file containing the fill-in fields.

pdfFileOutCharacter

The name of the PDF file to create or "AmazonS3".

If a filename is specified, the filename must include the name and path for the new PDF file created after merging the JSON data into the PDF file.

If "AmazonS3" is specified, the storageConnectionString and s3ObjectName must also be defined.

JSONDataCharacter

A JSON object that defines the values to populate the fields in pdfFileIn.

storageConnectionStringCharacter

A storage connection string to an S3 bucket where the output file will be uploaded. Required if pdfFileOut is set to "AmazonS3"

s3ObjectNameCharacter

Only required if pdfFileOut is set to "AmazonS3". The name of the object on S3 where the output file will be uploaded.

Returns

resultLogical

Returns .T. if the operation succeeds, otherwise .F..

Description

Merges data into a PDF file that has fill-in fields, creating a new PDF file with the filled in data. You can use the pdf_fillinFields_get() function to get the name of the fill-in fields in the PDF file.

This function wraps a 3rd party library which you must install yourself before you can use this function. The download link for this library is: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-win-setup.exe

The field values that you use in the JSON data must match the defined 'Export value' in the PDF form. In the PDF form designer, you can specify an 'export value' for each field. In the Example shown below, the 'Export value' for the 'football', 'baseball' and 'basketball' fields was defined as 'Yes'.

Example:

dim jsonData as c
jsonData = <<%str%
{
    "first_name": "Fred",
    "last_name": "Smith",
    "date": "12/18/2003",
    "football": "Yes",
    "baseball": "Yes",
    "basketball": "Off"
}
%str%

dim pdfIn as c
dim pdfOut as c
pdfIn = "c:\mypdffiles\pdfform1.pdf"
pdfOut = "c:\mypdffiles\pdfform1_filled.pdf"

pdf_fillinFields_merge(pdfIn,pdfOut,jsonData)