There are a number of ways you can do this. If it were me, I would create a single FDF file instead of multiple text files, and then import the FDF into the PDF, which would automatically set up the button actions for what you want. If you post a sample script, I could show a sample FDF the could do this.
So you could create a VBScript that opens the document, loops through the text files, reads them, and sets the button actions.
I've spent some time messing around with all of the options discussed above. This leaves me with some questions:
3) You mention an FDF file. I was trying to figure out exactly how to use it. It looks like a format that stores user input into fields without all the other junk that comes into a PDF. I created an FDF file from my PDF (which has only buttons, no text fields) and then viewed it as a .txt file to see what it would look like. There wasn't much there. For a PDF of 250 pages, the FDF file was something like 4 lines of text. So either I'm not accessing the FDF file correctly, or the FDF file doesn't contain information concerning buttons.
1. Yes, using the field.setAction method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.750.html
2. See #1
3. It is a specially constructed FDF, different from one that contains only field name/value pairs. I usually use the FDF Toolkit to create such FDF, but it can be done by other means as well.
4. See #1
In addition to George's answer to #3, you should have a closer look at the FDF section in the PDF specification (ISO 32000), part of the Acrobat SDK documentation (if I remember correctly, it is section 12.7.7).
FDF can much more than just transfer data from and to a PDF document, as it has been said.
And, it is rather easy to use a database to create the "core" of the FDF (and then either automatically or manually add the "additional stuff", making it a valid FDF. In fact, yours truly has been doing such things for more than a decade now…
Hope this can help.
Thanks to everyone who has helped me learn this stuff. I've been looking at the pages and references that you have given me so far. Now I can manipulate PDF with VBA code written in excel. It's very similar to the scrips shown for a standalone VB program, just some differences in document declaraion (particularly in using objects). I've noticed in the VBA (excel) script i can't get the "props" of an existing annotation, but I can for one that I'm just creating....
'Defining Stuff, I have alot more variables but I'm just showing the ones pertinent to my quandry.
Dim acroannotation As Acrobat.AcroPDAnnotDim props As VariantDim myAnnot As Object
Set myAnnot = jso.AddAnnot
Set props = myAnnot.getProps
Set acroannotation = Acropage.GetAnnot(1)
Set myAnnot = acroannotation
Set props = myAnnot.getProps
I noticed in the SDK, the examples show props being defined as an object just like 'myAnnot.' However, at the end of the VB tutorial, it indicates that I should use variant for most JSObject references. That doesn't really matter. What does matter is that I can't figure out how to get the 'props' object from an existing annotation. Am I doing something wrong in trying to reference it? It gives me the ole' Runtime Error 438: Object does not support this property or method, which usually means a type mismatch. I also tried "Set props = acroannotation.getProps", thinking that actually referencing the Annotation object instead of the "Object" object, but I still got the same error.
Finally, when I do figure out how to getProps for an existing annotation (the annotation is a button by the way, but I don't think that matters), I still have yet to find any reference as to how to use the "setAction" method for a button through the JSObject.
Thanks for any input on the matter.
When working with forms fields, you should be using the forms API: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/IAC_API_FormsIntro.107.2.htm l
Although you can do things indirectly via the JSObject too. A button is a type of form field.