7
Review, Markup, and Approval
Using Commenting Tools
Saving Modified Files into the Primary Document
Once an attached file has been modified, it may be saved once again. To embed its
contents into the primary document, invoke the
doc
object’s
getDataObjectContents
method in order to begin accessing its contents, and
setDataObjectContents
in order to save the modified contents, as shown in the code
sample below:
// Open the file:
this.importDataObject("myFile.txt", "/C/myFile.txt");
// access the FileStream (after which you may modify it):
var oFile = this.getDataObjectContents("myFile.txt");
var cFile = util.stringFromStream(oFile, "utf-8");
// now modify the string cFile
// ...
// Convert the modified string back to a FileStream:
oFile = util.streamFromString(cFile, "utf-8");
// Save the modified FileStream contents:
this.setDataObjectContents("myFile.txt", oFile);
Linking Between Files
You may set up links between files by setting the "Go to View" action of a link annotation. In
the case of nested PDF documents, intermediate documents automatically open. To use
Acrobat JavaScript to create a link, invoke the
doc
object’s
addLink
method. To cause the
link to open a file, set the
MouseUp
action to open the file.
Deleting Attachments
You may use Acrobat JavaScript to remove a file attachment from a document by invoking
the
doc
object’s
removeDataObject
method, as shown in the code below:
this.removeDataObject("myAttachment");
Spell-checking in Comments and Forms
You may check the spelling of any word using the
spell
object’s
checkWord
method.
This can be applied to any form field or annotation. First retrieve the contents, and submit
each word to the method.
Setting Spelling Preferences
To set the dictionary order, first retrieve the array of dictionaries using the
doc
object’s
spellDictionaryOrder
property. Then modify the order of the array entries, and
assign the array to the same property. An array of currently available dictionaries can be
obtained using the
spell
object’s
dictionaryNames
property.
132
Acrobat JavaScript Scripting Guide