-
1. Re: XML format for Acrobat JavaScript
Bernd Alheit Aug 26, 2009 3:18 AM (in response to DHeadrick)What you can see isn't valid XML. It is a mixture of XML tags and JavaScript.
-
2. Re: XML format for Acrobat JavaScript
GKaiseril Aug 26, 2009 7:37 AM (in response to DHeadrick)You should use the "Advanced => Document Actions => Document JavaScripts.." and this will bring up the editor for one script. Acrobat will add the necesssaryXML tags for the "Document All Scripts" as needed. There should be enough tools through Acrobat JavaScript and the FDF file to allow one to add or replace JavaScripts within a PDF.
If you have to, you can edit the JavaScript between the "XML" tags or psuedo XML tags.
The tags start with "//<" which is a JavaScript comment and and "XML" tag start. The tag ends with the ">". These tags indicate the location, form field, and action.
You should use the "Advanced => Document Actions => Document JavaScripts.." and this will bring up the editor for one script. Acrobat will add the necesssaryXML tags for the "Document All Scripts" as needed. There should be enough tools through Acrobat JavaScript and the FDF file to allow one to add or replace JavaScripts within a PDF.
If you have to, you can edit the JavaScript between the "XML" tags or pseudo XML tags.
The tags start with "//<" which is a JavaScript comment and "XML" tag start. The tag ends with the ">". These tags indicate the location, form field, and action.
-
3. Re: XML format for Acrobat JavaScript
DHeadrick Aug 26, 2009 10:54 AM (in response to Bernd Alheit)Thanks for the note. Yes, it looks like it's XML embedded as JavaScript comments.
-
4. Re: XML format for Acrobat JavaScript
DHeadrick Aug 26, 2009 11:07 AM (in response to GKaiseril)Thanks for your feedback. In my original posting, I indicated:
P.S. Another possible approach would be to create JavaScripts myself using
Advanced-->Document Processing-->Document JavaScripts, and then see what XML
is created based on the code I enter into the GUI, e.g. form code, functions, etc. This also
seems somewhat inefficient, presuming again that the JavaScript XML format is already documented.I double-checked my thinking on this my doing the above and, as I expected, it generated a fragment of the XML (or, rather, pseudo-XML) structure. I created a function and the XML that was generated was appropriate for the function (and just the function). I presume I'd need to next create, for example, a button with actions associated with it perhaps followed by a text box, also with actions associated with it, in order to see the XML that's generated in each case (such as parameters like "MouseDown" and pseudo-XML tags like "AcroForm").
Obviously, as I do this, I would see syntax patterns emerge between, for example, different types of form fields. However, rather than go through this seemingly hit-and-miss approach to understand the exact syntax, it would be very helpful if the JavaScript/XML syntax was documented. I presume it is documented somewhere but I just haven't found it yet.
Thanks again.
Dave
-
5. Re: XML format for Acrobat JavaScript
GKaiseril Aug 26, 2009 1:13 PM (in response to DHeadrick)This has been the way Acrobat has worked since version 4. You can change the editor to any true text editor that does not add formatting codes, so it is possible to have a better editor program that can support multiple windows. One can also add document level code by importing another PDDF with the necessary scripts.
One can also have more than one function within a document level script. Functions can support required and optional parameters and return values. These features allow for the creation of flexible functions that can provide a wide range of results depending upon how well one can code some tool code.
To add code to form fields, you need to create the form field and locate the appropriate tab and enter the necessary code. This is safer than trying to add the necessary tagged code.
There are also ways to automate the generation of JS code or compute field names used the JS code so this combined with loop controls available to JS can result in some efficiency of coding when properly used along with some good document level functions.
If you have access to older versions or Acrobat, you could look at the source JS code that is used to provide the formatting, keystroke, validation, and simple computation routines.
For a simple example see:
Concatenation Problem , http://forums.adobe.com/thread/479802?tstart=0
For an example on how to join the pieces of a name to create an email address, full name and reversed name and automatically adjuting for missing data like a middle name. The document level scirpt was from a sample provided by Adobe with Acrobat version 4.
-
6. Re: XML format for Acrobat JavaScript
DHeadrick Aug 27, 2009 7:12 PM (in response to GKaiseril)Thanks for the additional information.
I played with JavaScript some more, using my preferred editor, UltraEdit, which I attached to Acrobat. I thought I would be able to take a JavaScript program from one PDF file (source file) and do a copy & paste into another PDF file (destination file). While I can do the paste (again, via UltraEdit) into the destination file and can do an UltraEdit Save, when I go back into UltraEdit via Advanced --> Document Processing --> Edit All JavaScripts, the JavaScript I pasted from the source file to the destination file isn't there in the destination file.
From this, I concluded that I'll need to create the Document-level JavaScript and the form field Javascripts (e.g. a JavaScript triggered by a "Mouse Down" in a button) via the Acrobat GUI's. Acrobat doesn't seem to like it if I bypass the GUIs and just attempt to paste the code directly into the PDF file via an editor. By not using the GUI and just doing the cut & paste as I did, I'm probably missing some part of the code setup/creation process that Acrobat needs to know about.
This is why I originally asked about the syntax for the pseudo-XML, thinking I could just copy the pseudo-XML/JavaScript code from one PDF file to another, and then modify the code to reflect the needs of the destination PDF. Now I understand the need you mentioned to use the Acrobat GUIs to set up the initial XML/JavaScript structure.
Once I have the XML structure set up in the destination file (e.g. a JavaScript triggered by a "Mouse Down" in a button), I can obviously copy code snippets into that <AcroForm> sections, I just can't *create* the original "Mouse Down" <AcroForm> sections via the editor.
Another approach I could follow would be to make a copy of the original source file and change the name of the copy to the desired destination file name, and then start modifying the code in the new (destination) file -- presuming that's the easiest path to get the desired functionality created. This way, I wouldn't have to manually (via the Acrobat GUI) create all of the <Document-Level> and <AcroForm> sections.
Thanks for your (and others') help, let me know if I'm missing anything.
Dave


