Jump to content
Sign in to follow this  
Jfish

PDF manipulation - importing data from FDF file

Recommended Posts

Jfish

I am a newbie self-taught programmer who probably has little business trying to work with APIs and COM/OLE. However, that has not stopped me from attempting it. To that end, I found John Bailey's post (at: http://www.autoitscript.com/forum/index.ph...;hl=pdf+bailey) with the acrobat_InterApplication_Communication_API.au3 script very interesting and helpful.

My goal is to open an instance of Adobe Acrobat with a specific form (attached) and import an FDF file (see below) using objects. I leveraged Bailey's script to open the specific file. I have an FDF file that is ready to be imported in Acrobat for a spefic form. I want the form that has been opened to automatically import this file. I am very stuck at the moment. Here is what I have done...

#include <Acrobat_InterApplication_Communication_API.au3>

dim $oApp = ObjCreate("AcroExch.App") ;create acrobat application object

$oApp.Show ;show the acrobat application

dim $aic_FiletoOpen = @ScriptDir&"\AZ-crack.pdf" ;name the file that we would like Acrobat to open

dim $oAVDoc = _AcrobatIC_AVDocOpenNew($oApp,$aic_FiletoOpen) ;open the file within Acrobat

#comments-start

I picked this up off of PlanetPDF and have been trying to follow it to no avail:

* Create an application "AcroExch.App" object.

* Create a form "AFormAUT.app" object.

* Set an AVDoc object = appliation.GetActiveDoc()

* Use the AVDoc to open a template of the PDF to be merged

* Set a fields object = form.fields

* Import the FDF file from earlier using fields.ImportAnFDF

As you can see, all I have really been able to do is use the Bailey script to open the appropriate file. Now I am trying to instantiate a fields object so that I can call the Acrobat plugin (mentioned in the link on John Bailey's posting to the iac_api_reference.pdf doc) with the method "ImportAnFDF." However, I am not sure how to do that. Any help would be greatly appreciated.

Here is my feable attempt:

dim $oForm = ObjCreate("AFormAut.App") ;presumably create forms object

dim $oFields = ObjCreate($oForm.fields) ;attempts to create fields object

$oFields.ImportAnFDF($fdf); It won't recognize this method from the plugin - attempts to import fdf to fields

It won't let me upload my fdf file so here it is:

%FDF-1.3

1 0 obj

<<

/FDF << /Fields [

<< /V (John Smith) /T (Claimant Name) >>

<< /V (2587) /T (AgGallons) >>

<< /V (1000) /T (AGallonsT) >>

<< /V (Director) /T (City) >>

<< /V (MA) /T (State) >>

<< /V (02110) /T (Zip) >>

<< /V (12569872) /T (Phone) >>

<< /V (October 22, 2008) /T (Begin) >>

<< /V (555 Mokcingbrid Lane) /T (Address) >>

<< /V (November 22,2008) /T (End) >>

]

/F (file name) >>

>>

endobj

trailer

<<

/Root 1 0 R

>>

%%EOF

#comments-end

Any help or guidance would be greatly appreciated!

Thanks,

Jfish

az_crack.pdf


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
ReFran

I think no problem to do what you want.

But why you want to import via FDF.

You can do it direct with the script (something like var f = getField(); f.value = "blabla").

Best regards, Reinhard

Edit: What you have (Full Acrobat Version x or Reader only)?

Edit: By the way, wrong subforum, question like this should be under "General Help and Suppurt".

Edited by ReFran

Share this post


Link to post
Share on other sites
ReFran

Mmmh,

I assume you know, that you can start the PDF direct with the FDF if you state a OS-independent full filename (path)?

Example: I took your pdf and saved it as c:\index.pdf.

Then in the FDF file (plain text file with special structure) you have to state the /F key in this form: (/c/index.pdf)

You can save that with the ext .fdf and doubleclick on it to load the PDF filled up with the data from the FDF.

That means in your script you need only a Run or Shellexecute statement to do what you want.

Best regards, Reinhard

IndexDat.fdf

--------------------------------

%FDF-1.3
1 0 obj
<< 
/FDF << /Fields [
<< /V (John Smith) /T (Claimant Name) >>
<< /V (2587) /T (AgGallons) >>
<< /V (1000) /T (AGallonsT) >>
<< /V (Director) /T (City) >>
<< /V (MA) /T (State) >>
<< /V (02110) /T (Zip) >>
<< /V (12569872) /T (Phone) >>
<< /V (October 22, 2008) /T (Begin) >>
<< /V (555 Mokcingbrid Lane) /T (Address) >>
<< /V (November 22,2008) /T (End) >>
] 
/F (/c/index.pdf) >> 
>> 
endobj
trailer
<<
/Root 1 0 R 
>>
%%EOF

Share this post


Link to post
Share on other sites
Jfish

It is dangerous to assume I know anything ;-) Thanks for the reply, I will try that!

Mmmh,

I assume you know, that you can start the PDF direct with the FDF if you state a OS-independent full filename (path)?

Example: I took your pdf and saved it as c:\index.pdf.

Then in the FDF file (plain text file with special structure) you have to state the /F key in this form: (/c/index.pdf)

You can save that with the ext .fdf and doubleclick on it to load the PDF filled up with the data from the FDF.

That means in your script you need only a Run or Shellexecute statement to do what you want.

Best regards, Reinhard

IndexDat.fdf

--------------------------------

%FDF-1.3
1 0 obj
<< 
/FDF << /Fields [
<< /V (John Smith) /T (Claimant Name) >>
<< /V (2587) /T (AgGallons) >>
<< /V (1000) /T (AGallonsT) >>
<< /V (Director) /T (City) >>
<< /V (MA) /T (State) >>
<< /V (02110) /T (Zip) >>
<< /V (12569872) /T (Phone) >>
<< /V (October 22, 2008) /T (Begin) >>
<< /V (555 Mokcingbrid Lane) /T (Address) >>
<< /V (November 22,2008) /T (End) >>
] 
/F (/c/index.pdf) >> 
>> 
endobj
trailer
<<
/Root 1 0 R 
>>
%%EOF

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
Jfish

That method with the filename included in the FDF file and the shell execute command worked like a charm. Thanks for that info! I think that I saw in your post that you thought I could manipulate the Adobe object to this as well. Could you explain how to do this that way?

It is dangerous to assume I know anything ;-) Thanks for the reply, I will try that!


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
ReFran

Full Adobe Acrobat Version (notReader only)?

Which Version?

Reinhard

Share this post


Link to post
Share on other sites
ReFran

Here the import solution. Works with above stated example.

Works only with full version of Adobe Acrobat.

Best regards, Reinhard

;; C:\AcroImp.au3

$fileForm = "C:\Index.Pdf"
$fileImport = "C:\IndexDat.fdf" 

$App = ObjCreate("AcroExch.App") 
$App.Show                       
$AVDoc = ObjCreate("AcroExch.AVDoc") 


If $AVDoc.Open($FileForm,"") Then 
   $PDDoc = $AVDoc.GetPDDoc() 
  ;; pure JSO Solution
   $JSO = $PDDoc.GetJSObject 
   $JSO.importAnFDF($fileImport)
endif

Share this post


Link to post
Share on other sites
Jfish

I have the full Acrobat. I will try your solution tomorrow. Thanks for that response as well. I really appreciate your taking the time to help me out.

Here the import solution. Works with above stated example.

Works only with full version of Adobe Acrobat.

Best regards, Reinhard

;; C:\AcroImp.au3

$fileForm = "C:\Index.Pdf"
$fileImport = "C:\IndexDat.fdf" 

$App = ObjCreate("AcroExch.App") 
$App.Show                       
$AVDoc = ObjCreate("AcroExch.AVDoc") 


If $AVDoc.Open($FileForm,"") Then 
   $PDDoc = $AVDoc.GetPDDoc() 
 ;; pure JSO Solution
   $JSO = $PDDoc.GetJSObject 
   $JSO.importAnFDF($fileImport)
endif

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
Jfish

I have the full Acrobat. I will try your solution tomorrow. Thanks for that response as well. I really appreciate your taking the time to help me out.

I apologize, I realize I never responded to let you know the object method worked as well. It was important to me because I am trying to learn COM (with little sucess). Again, I appreciate your taking the time. Thanks much.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×