These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Automate merging Form data with VB

OC
Registered: Apr 16 2009
Posts: 5

Hello,
I've created a simple form using LiveCycle Designer with repeating subforms.
I can create xml files with data for our students.
I can manually merge an xml file with the PDF form (using acrobat menus to import form data) to create a form with a students data, and email that to a student. The form has a button to email back the xml data from the form after they have udated the data and that seems to work fine.
Now I need to do that for 900+ students...
I've used the acrobat api/com objects in VB to work with PDF forms (adding, removing, replacing pages mostly). What I'm hoping is that there is a way to use vb to:

Open my template form
Load/Import a student's xml data file.
Save the form with a student specific name.
repeat....I have code to handle mailing the filled in forms to each student.

At this points it is how to load/import a students data that I am stumped. I'd like to do this using VB or VBA. Will consider Java.
At the moment we are using acrobat 7.0 and LiveCycle 7.0, but we are upgrading to 8.0 or 9.0, as we would also like to extend the reader rights to allow them to save their forms after updating the forms data with reader.
Thanks for any help!

My Product Information:
LiveCycle Designer, Windows
garath
Registered: Mar 24 2009
Posts: 49
Hi,
There are few options, which You can use. I developed almost all of them, so I know pros and cons of them:)
1) Using COM object - I didn't do data merge with this but it was always painful for me
2) Writing a plugin for Acrobat - very powerful, but You need time for this
3) Using Javascript and some tricks (e.g. add something in windows registry) - very useful and usually fast. Unfortunately there are lot of problems with debugging.
4) Using XDP files - basically You send XML instead of PDF files. You put PDF on WWW server and link to it from PDF. I'm not sure how XDP files works in Adobe Reader 7 but in 8 and 9 they work very good.

If you need more help or would like to see some demo, I can prepare it for You. I'm sorry for self-advertising but I'm looking for job:) So if you need a consultant or prefer to outsource this project please write me. I can do this for You.
Regards
OC
Registered: Apr 16 2009
Posts: 5
I think I have solved my problem, at least as far as generating the forms is concerned. Still need to upgrade acrobat to test for the extended reader rights, and ability for forms to be saved with updated data in reader...I'm sure more details to be ironed out, but at least now I can automatically generate forms with the required data.

My solution was the following:
Create my template pdf form using designer.
I need to send a pre-filled pdf via email, I could not send xdp that referenced a file on the www.
I manually entered some form data, then exported the data as an XDP file.
I used the XDP file format as my template to create individual unique data files for each student. Each file referenced the template pdf form.
My vb program then:
Opens acrobat
loops through the list of students, opens their xdp file.
Now there is the template PDF with the students data open.
Save this pdf using the student id.
Repeat for each student.

Here is an example:

Private Sub Command1_Click()
Dim mAcroExchApp As AcroApp
Dim AcroExchPDDoc_Merged As AcroPDDoc
Dim AcroExchAVDoc_Merged As AcroAVDoc
Dim strXDPName As String
Dim strOutputFileName As String
Dim i As Integer
Set mAcroExchApp = New AcroApp
'optional, Show the Acrobat window
'mAcroExchApp.Show
For i = 1 To 5
strOutputFileName = "C:\testing\Output\" & i & "9999_StudentInfo.pdf"
'the xdp files contain a reference to the form template, C:\testing\XDP_Data\XDPTest_Template.pdf
strXDPName = "C:\testing\XDP_Data\" & i & "9999_XDPTest_data.xdp"'open the xdp file
Set AcroExchAVDoc_Merged = New AcroAVDoc
AcroExchAVDoc_Merged.Open strXDPName, "Temp"
DoEvents'get the PDDoc for the pdf
Set AcroExchPDDoc_Merged = AcroExchAVDoc_Merged.GetPDDoc
DoEvents
'save using the new name
AcroExchPDDoc_Merged.Save &H1, strOutputFileName
'close files
AcroExchPDDoc_Merged.Close
AcroExchAVDoc_Merged.Close 1
DoEvents
Next i
Set AcroExchPDDoc_Merged = Nothing
Set AcroExchAVDoc_Merged = Nothing
mAcroExchApp.Exit
Set mAcroExchApp = Nothing
MsgBox "Done"
End Sub
OC
Registered: Apr 16 2009
Posts: 5
Well, looks like we must abandon this. The form merging part works great. But extending reader rights to allow users to save their form data changes is the killer. We do not want to violate the Acrobat Pro EULA restriction on 500 reciepients (which we would), and licensing extending reader rights is way more expensive than we can afford.
It will be a useful approach to send out pre-filled forms, in any instances where users would not need to make and save changes to the data.