Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get the pagenumber of bookmark with JavaScript?

1,878 views
Skip to first unread message

Andrew Klimenko

unread,
Jun 17, 2003, 1:56:12 PM6/17/03
to
There is an example of dumping the names of all bookmarks in Acrobat JavaScript document. I need to generate list with name of bookmark and number of page of this bookmark. But object "Bookmark" in Java Script doesn't have property which contains the number of page of referenced document.
The "doc" property have "pageNum", but it contains the current pagenumber of opened document.
So, how can i generate such list?

Reinhard Franke

unread,
Jun 18, 2003, 5:48:16 AM6/18/03
to
Execute the bookmark = jump to the page and get the pagenumber. If you put this into your example (List all bookmarks) then you can get a TOC with pagenumbers.

HTH, Reinhard

Andrew Klimenko

unread,
Jun 18, 2003, 9:15:09 AM6/18/03
to
Thank you, but i've tried this way.
Even after the "executing" the bookmark the property pageNum of doc object doesn't changes it's value.
So, the result of the execution of the following JavaScript:

//---------------------------
function Dump(bm)
{
console.println(bm.name);
bm.execute;
console.println(this.pageNum);
if (bm.children != null)
for (var i = 0; i < bm.children.length; i++)
Dump(bm.children[i]);
}
//---------------------------
Dump(this.bookmarkRoot);
//---------------------------
is not the TOC. It returns the list with name of the bookmark and the number of page on which current document is opened - the constant value. :(

Reinhard Franke

unread,
Jun 18, 2003, 12:11:44 PM6/18/03
to
Try somthing like this (quick shot):

var f=""
function DumpBookmark(bm, nLevel)
{
var s = "";
for (var i = 0; i < nLevel; i++)
bm.execute();
p = this.getPageLabel(this.pageNum);
s += " ";
f += (s + bm.name +"..." + p + "\n");
app.alert(f);


if (bm.children != null)
for (var i = 0; i < bm.children.length; i++)

DumpBookmark(bm.children[i], nLevel + 1);
}
DumpBookmark(this.bookmarkRoot, 0);

HTH, Reinhard

Andrew Klimenko

unread,
Jun 19, 2003, 11:29:15 AM6/19/03
to
Actually, the previous function is correct... Almost...
I've fixed one line:

bm.execute();

And now it works.
Thanks!

0 new messages