Uderc programming article aggregator sites

How to print bookmark into a PDF File?

Answers: Have 5 answers
Hi community
I have a PDF-File with a few pages and need to have on each page the bookmark printed as a text.
I tried with Javascript, and can print the filename but not yet the bookmarks.
I have following script:
app.addMenuItem({cName:"Print Filename", cParent:"File", nPos:20, cExec:"PrtFN();"});
//Print Filename to Pages
function PrtFN()
  for (var p = 0; p < this.numPages; p++)
    var fd = this.addField("Print Bookmark", "text", p, [563,519,790,545]);
    fd.value = (this.documentFileName);
Do someone of you know how to print the bookmarks, something like "fd.value = (this.documentBookmark);" ?
Thanks for helpful answers!
The best answer: It is possible to get a bookmark name from the bookmark object but as noted a reverse lookup for a bookmark to a given page is not fool proof.
You could write a script that walks the bookmark tree and then use execute to go to the page that book mark points too and then fill-in the bookmark name. This assumes all bookmarks perform the go to page/view action and do not run a script or open another PDF. You may also need to account for more than one bookmark pointing to a page.