7
Review, Markup, and Approval
Managing Comments
Sorting Comments
If you would like to sort comments using Acrobat JavaScript, you may do so by submitting
an optional parameter to the
doc
object’s
getAnnots
method. The
nSortBy
parameter
may be assigned one of the following values:
●
●
●
●
●
ANSB_None
:
Do not sort.
ANSB_Page
:
Sort by page number.
ANSB_Author
:
Sort by author.
ANSB_ModDate
:
Sort by modification date.
ANSB_Type
:
Sort by annotation type.
In addition, you may specify that the sorting be performed in reverse order by submitting
the optional
bReverse
parameter to the method.
The code sample given below shows how to obtain a list of comments from page 2 of the
document, sorted in reverse order by author:
this.syncAnnotScan();
var myAnnotList = this.getAnnots({
nPage: 2,
nSortBy: ANSB_Author,
bReverse: true
});
Showing and Hiding Comments
To use Acrobat JavaScript to show or hide a comment, set its corresponding
annot
object’s
hidden
property. For example, the following code hides
myAnnot
:
myAnnot.hidden = true;
Finding Comments
There are two ways to use Acrobat JavaScript to find a comment. If you know the name of
the comment, you may invoke the
doc
object’s
getAnnot
method. Otherwise you may
obtain all the comments by invoking the
doc
object’s
getAnnots
method, and iterate
through the list.
The
getAnnot
method requires two parameters: the page number and the name of the
annotation. The following code sample shows how to obtain a comment on page 2 named
knownName
:
var comment = this.getAnnot(2, "knownName");
138
Acrobat JavaScript Scripting Guide