Domino Data Into a PDF the Easy Way - activePDF Toolkit
Have you ever wished that you could easily merge data from a datasource into a predefined PDF form? I have this requirement all of the time.
My organization gets PDFs from the various states' departments of insurance and work comp boards like this one (needs Acrobat to view.)
Continue to see the simple code we use to accomplish this via a PDF toolkit from actvePDF
Here is some LotusScript code (but it could be any language that can contain a COM object) that does ALL of the work for you
Dim pdf as Variant, r as Variant
Set pdf = CreateObject("APToolkit.Object")
r = pdf.OpenOutputFile(gs_OutPutPath & key & ".pdf")
r = pdf.OpenInputFile(gs_InputPDF)
r = pdf.SetFormFieldData("4", doc.ssn(0), -997)
...
r = pdf.SetFormFieldData("5", Cstr(doc.dob(0)), -997)
r = pdf.CopyForm(0, 0)
r = pdf.CloseOutputFile()
Declares a couple of containers that will hold our COM object (PDF) and a operation result values (r) (You are using Option Declare/Explicit, aren't you?)
Instantiates the activePDF Toolkit COM object
Points the COM object to the file path where you want your new pdf file stored and names the file
Points the COM object to the current PDF 'template form'
Is an example of setting a field on the pdf to a value from a Domino document, in this case a social security number, the first parameter, '4', indicates a field name already assigned on the PDF template form (as in a field named "4", not the sequential number of a field); the 2nd parameter is the value to be written into the field, and the third parameter is a constant that allows you to control the fields future behavior (in this case we are locking the field from any future edits.)
Indicates more fields to be set
Is an example of setting a field on the pdf to a value from a Domino document, in this case a date of birth, notice that PDF only accept string values</li>
Merges the data into the fields with the template form and creates a new PDF file.
Closes the file and returns the COM object's memory to the system.
Pretty simple huh? We have installed the toolkit on the same machine as our Domino server and have this code in an agent that can be launched from our secured portal by either our employees or our policyholders. This particular piece of code populates a First Report of Injury form from data submitted by our policyholders. We save the PDF to a HTTP accessible folder (secured) and then return the redirected HTTPS URL to the browser which then opens the PDF in the browser. Our policyholder rave about this functionality and it was very simple to create: $900 for the toolkit and less then an hour of coding = very happy policyholders and employees (both of whom previously would manually enter the data into the PDF.)
We have extended this functionality into various workflows and PDFs that we are required to submit to various external agencies. We have scheduled agents that look for records that meet the criteria, populate the form, save it to a file, create an email, attach the PDF and mail it out. All hands free and laborless, just the kind of easily demonstratable ROI that the big Cs love.





