Skip to main content
Participant
March 9, 2021
Question

Autofill PDF form fields with Site Data using Javascript

  • March 9, 2021
  • 2 replies
  • 2682 views

Having a bit of trouble connecting things I know are possible to do with JS and PDFs.

 

My site needs to generate agreements forms with customer data that is already retained in our site database. I have a copy of the PDF form with Form Fields in blank spaces where I would like the data to fill in.

 

I would like our agents to click a button on the site and a function retrieves the original PDF form with Form Fields then, using the captured data from our database, automatically fills the correct form fields with matching data.

 

The function then saves this as a new PDF to our server.

 

The agent is then able to pull up that new PDF with the filled data to have the customer sign.

 

How would I complete this? 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
March 9, 2021

I think this would require a server-side solution, an application that retrieves the data from a database, populates the PDF form fields with it and then serves it to the end-user. This goes beyond the scope of Acrobat and will require a stand-alone tool or script to perform this task.

 

I've created similar tools in the past for my clients so if you're interested in hiring someone to do it for you feel free to contact me privately via [try6767 at gmail.com] to discuss it further.

Thom Parker
Community Expert
Community Expert
March 9, 2021

There are a couple of workflow options for this.

1) Merge Data on Desktop:  Agent presses a button in Acrobat (could be on the form or it could be on the toolbar). The button sends a request to the server. The Server generates a PDF compatible data format and returns it to  Acrobat which merges the data into the form.  If FDF is returned the PDF doesn't have to be open, because the FDF can contain a link to the sepcific file that matches the data. Acrobat will load both and merge them. 

 

2) Merge Data on the server:  This requires a PDF library or tool on the server that has this capability. There are many.   In this case, a request from Acrobat would return the PDF instead of the data. Or a link on a website could trigger this action.  

 

So I think it is #1 that you are really interested in. I don't think the exact workflow you descibed is reliable, i.e. pushing button on the website. The reason is that it is Acrobat that merges the data.  It's possible that a retured FDF file will automatically be opened in Acrobat, but this is the unreliable part. Of course, since these are your agents, then maybe you can enforce a setup there this does happen reliably.    

 

I don't have a lot of material on this topic, but you can read more about Acroat, PDF and Data here:

https://www.pdfscripting.com/public/Form-Data-Handling.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often