Using the JavaScript Disclosed Document Property

A property of the Doc object of a PDF is the ‘disclosed’ property (introduced with a patch to Acrobat 5.0). Depending on whether this property is set to true or false determines whether a PDF can be accessed by JavaScript from within other PDF documents. Specifically, if the disclosed property is set to false, you will be unable to access the ‘Doc’ object of a PDF unless it’s the active PDF document in Acrobat.

A typical example of this is using the App.openDoc() method from a PDF link to open a separate PDF document. This would have worked without problems in previous versions of Acrobat, but unless the disclosed property of the PDF you’re trying to open is set to ‘true’, the PDF will NOT open with Acrobat.

To individually set the disclosed property on all your PDFs would be a labourious task if you have more than a handful of PDFs. However, using a little JavaScript and Acrobat Batch Processing you can set this property to true across your whole collection of PDFs. Note: Batch Processing in Acrobat 6.0 is only available in the Professional version.p>

So in Acrobat:

  1. Acrobat 6.0 – Open Batch Processing from the ‘Advanced’ menu.

    Acrobat 5.0 – Open Batch Processing from ‘File > Batch Processing > Edit Batch Sequences’

  2. Click ‘New Sequence’ and give a name to your new sequence.

  3. Click ‘Select Commands’ and add ‘Execute JavaScript’ as the action to execute.

  4. Double click on the ‘Execute JavaScript’ selection in the right dialog pane and add this JavaScript code to the window. Click ok.

    /* Insert document level JavaScript to set disclosed = true.
    This will run when the document is opened.*/

    this.addScript(‘setDisclosed’, ‘this.disclosed = true;’);

  5. Finish creating your Batch Sequence by designating an output location and configuring sequence run conditions. Return to the main Batch Sequences dialog and select your new Batch Sequence to run it on your PDF collection. Once processed, these documents will be accessible from JavaScript in separate PDFs.

You May Also Like

About the Author: Chris Dahl

Leave a Reply