10 Replies Latest reply on Aug 7, 2015 1:08 AM by try67

    Adobe Javascript works in Debugger but fails otherwise




      I am trying to attach a file ( from my local system ) to a given pdf document which I have opened. This script works well when I try to execute in embedded javascript debugger present in Adobe reader ( I have to do some tweaks to be able to view the debugger in Adobe reader XI which is not present by default).

      On saving the below script in my Javascript folder, and on launching adobe, I expect file to get attached to pdf but it is failing at this function. Not sure what is the reason behind it, because my motive is to call the the javascript through a vba code and do some automation. Any suggestions ?


      Java script



      try {

          var annot = this.addAnnot({

              page: 0,

              type: "FileAttachment",

              point: [250, 750],

              noView: true,

             cAttachmentPath: "/C/test.tbi",

              author: "ABC"


          var attachmentObj = annot.attachment;

          if (attachmentObj !== null) {

                app.alert("Name " + attachmentObj.name);

              var l = this.getField("lst");

              console.println( "Inside file attachment part" )

              l.insertItemAt(attachmentObj.name, 0);




        app.alert( "File Attachement part - Inside Else" )



      catch(e) {

          app.alert("This File Attachement Failed" )

          if (e.name == "NotAllowedError") {

              // do nothing

        app.alert("File Attachement Failed" )



      // have to disable Protected View in Preferences -> Security(Enhanced) -> Enable protected mode at startup and Enable enhanced security