Skip to main content
andyji
Participant
May 4, 2017
Answered

Programmatically Creating a Bookmark To a Page Without JavaScript Actions

  • May 4, 2017
  • 2 replies
  • 2941 views

I am using JavaScript to programmatically create bookmarks to specific pages (e.g. bookmarkRoot.children[0].children[0].createChild("My Bookmark", "this.pageNum=77");).

This works but I am sending the PDF to a company who do not allow JavaScript within documents. Is there a way to set a bookmark to a destination page programmatically without associating it with a JavaScript action?

I can go into the document, click on each bookmark to go to the correct page, then select Set Destination and that will replace the JavaScript actions with Adobe actions but I have to do this for many documents so would like to find an automated way of doing it.

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

You cannot do this with JavaScript, you would need a plug-in to do that. There are some 3rd party plug-ins that can read e.g. a text file and apply bookmarks  (e.g. EverMap's AutoBookmark Plug-in - AutoBookmark Plug-in for Adobe Acrobat - PDF Bookmarking Functionality​) , but if you want true programatic control over what goes where, you would need a custom plug-in, or a standalone application. A while ago I created that functional as part of a larger system in an Acrobat plug-in. If you are interested in a custom solution, please get in touch with me directly.

2 replies

Karl Heinz  Kremer
Community Expert
Karl Heinz KremerCommunity ExpertCorrect answer
Community Expert
May 4, 2017

You cannot do this with JavaScript, you would need a plug-in to do that. There are some 3rd party plug-ins that can read e.g. a text file and apply bookmarks  (e.g. EverMap's AutoBookmark Plug-in - AutoBookmark Plug-in for Adobe Acrobat - PDF Bookmarking Functionality​) , but if you want true programatic control over what goes where, you would need a custom plug-in, or a standalone application. A while ago I created that functional as part of a larger system in an Acrobat plug-in. If you are interested in a custom solution, please get in touch with me directly.

andyji
andyjiAuthor
Participant
May 4, 2017

Thanks Karl

I downloaded a trial version of the Evermark plug in and it seems to do everything that I need. I'll let you know if we need a custom solution.

Joel Geraci
Community Expert
Community Expert
May 4, 2017

No. At least not with Acrobat JavaScript. What authoring tool are you using to write the document?

andyji
andyjiAuthor
Participant
May 4, 2017

Thanks for the quick response Joel.

The documents have been created externally and I am not sure what authoring tool was used. I just need to add the bookmarks. I'm using an open source tool (XPDF) to extract the text from the PDF, reading that in programmatically with SAS to pick out the information for the bookmarks and generating the JavaScript code to create the bookmarks.

Do you know of any alternatives to using JavaScript?

Joel Geraci
Community Expert
Community Expert
May 4, 2017

See Karl's answer above for alternatives. You may be able to remove XPDF from the process by using a plug-in.