Skip to main content
Participant
July 19, 2023
Question

Getting Variables From One Document and Using Them in Another Using Javascript (Thom Please Help!)

  • July 19, 2023
  • 1 reply
  • 265 views

Hi Thom, I'm a huge fan!

I need to read the bookmarks from one document as variables and use them in a action sequence I made that is used on a different document. I am only just learning Javascript (I'm an intern). I read something you wrote about golbal variables, but when I tried to use these methods the variables I assigned were undifined. I also found a way to do something similar to what I want in the UI using thumbnails, replace pages to replace all the pages in the first document with the pages in the second document while keeping all the bookmarks, but this has some of its own problems and I am supposed to make this program very simple for the users.

I was wondering if this process is possible using pdf javascript, and if so how would I go about that. Any help would be greatly appreciated. 

Thanks Thom!

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
July 19, 2023

What exact feature of the bookmarks do you want to use?  In general, bookmarks have three important characteristics:

1. The  Label

2. The hierarchy 

3. The Action

 

The label and hiearchy can by copied from one document to another. But the Action is usually a destination that is specific to the document. Further, the Action is not accessible to JavaScript, so nothing can be done with it. 

 

About the global object. Look at the JavaScript settings. They default to project the global to restrict access to the single document where they are defined. You can change the setting or change your script to access them from a privileged context. 

https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
July 19, 2023

Thanks so much Thom! You are the best! I just needed the labels