Skip to main content
deckarduk
Inspiring
June 4, 2020
Question

Acrobat Javascript code works in debugger but not on button?

  • June 4, 2020
  • 1 reply
  • 355 views

Hi there,

Please can someone point me in the right direction.

I've put together some JS that reads a list of pdfs from a text form field.

For each file in the list a master pdf is opened, pages replaced and then the pdf is saved to a folder.

Paths to the files are set up with - var pathToThis = this.path.replace(this.documentFileName,""); which gives me the base location.

The code works fine in the JavaScript Debugger however when I take the code and add it to a button mouse up trigger it fails.

I've also tried putting the JS into a document level script but still it fails.

Is there some other way I can execute the JS outside of the Debugger? I was thinking of creating a custom menu item but I'm not sure if that would work.

Please can someone help?

Thanks in advance.

    This topic has been closed for replies.

    1 reply

    try67
    Community Expert
    Community Expert
    June 7, 2020

    For future reference, you should post Acrobat JS questions here: https://community.adobe.com/t5/acrobat/bd-p/acrobat

     

    There's a big difference in what you can do from the JS Console and what you can do from a button.

    This is part of a complicated subject called trust and privilege. You can find more information about it here:

    https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts

    Bottom line is that in order to do what you described you will need to modify your code and place it in a folder-level script, and then call it from your button (either in the file or the application itself).