20 Replies Latest reply on Jun 22, 2016 6:07 AM by Test Screen Name

    app.openDoc

    frankrenner2011

      Hello,

       

      I have a problem with Acrobat 10.0 on Windows. I have read the Scripting Reference and other guides and searched all forums for a few days now and can still find no answer (although I find a few unanswered postings with the same question).

       

      When I use app.openDoc in a trusted function at application folder level, I still get the "NotAllowedError" when calling the trusted function from a MouseUp event of a button object.

       

      So I ask myself:

       

      - Is it generally possible to open another PDF document from a MouseUp event of a button object?

      - Are there any working examples of where (folder level and object level) to put which code for achieving this?

       

      What I do is having a a function "trustedOpenDoc" at application folder level:

       

      trustedOpenDoc = app.trustedFunction(

           function(pPath) {

                app.beginPriv();

                     app.openDoc({

                          cPath: pPath,

                          bUseConv: true

                     });

                     app.endPriv();

                }

      );

       

      And I call it from a button object in this way:

       

      mainDoc = trustedOpenDoc("/C/myDoc.pdf");

       

      Still I get the NotAllowedError. Doing the same with app.newDoc works perfect.

      Any advice? I'm close to desperation with this issue. Thanks in advance for any hints.

       

        • 1. Re: app.openDoc
          gkaiseril MVP & Adobe Community Professional

          Adobe introduced the document property 'disclosed' with version 5.05  You need to set this property to logical 'true' within the PDF you will be trying open at a later date. You add a document level script to perform this action.

          • 2. Re: app.openDoc
            frankrenner2011 Level 1

            Thank you very much. I have already been using this on earlier projects and forgot about it as I was out of the race of Acrobat scripting for some years. Very helpful, very time saving!

            • 3. Re: app.openDoc
              try67 MVP & Adobe Community Professional

              There's another problem with your code.

              If you intend on using mainDoc later on in the main script then you need to add a return command to your trusted function.

              At the moment, since your trusted function doesn't return anything, the file might open, but mainDoc will be null.

              • 4. Re: app.openDoc
                frankrenner2011 Level 1

                Thank you, I had already noticed this. But the most important thing is that there is no need to run app.openDoc within a trusted function. As soon as the "disclosed" property is set to true in the main document, openDoc will work fine in a document level function.

                • 5. Re: app.openDoc
                  rajavardhanr3623689

                  same issue m facing when i try to access "app.newDoc()",Displaying Error: Security settings prevent access to this property or method.

                  even I unchecked protected mode in secuity(enhanced) category in also javascript settings  enabled all javascript debugger.
                  app.newDoc() is placed in trusted function ,even we are using this.disclosed=true property also.Please anyone can help out

                   

                   

                   

                  Thanks in advance

                  1 person found this helpful
                  • 6. Re: app.openDoc
                    try67 MVP & Adobe Community Professional

                    Post your full code, please.

                    • 7. Re: app.openDoc
                      gkaiseril MVP & Adobe Community Professional

                      In what action are you trying to use this code?

                       

                      Have you checked the Acrobat JavaScript documentation for the app.openDoc method?

                       

                      The second note reads:

                       

                      "The app.openDoc API cannot be called from a doc open script. A script which is executed on the doc open action is known as doc open script. In such cases, Viewer raises a NotAllowedError exception, which escript passes to the user. However, it can be called successfully from other triggers, such as a page open action."

                       

                      I would take this to mean one cannot use this method as part of a documents level script that is executed during the document opening process.

                      • 8. Re: app.openDoc
                        maxwyss Level 4

                        That "Security settings prevent access…" error message may be completely misleading.

                         

                        It does also appear when the file you try to open simply does not exist.

                         

                        Hope this can help.

                        • 9. Re: app.openDoc
                          rajavardhanr3623689 Level 1

                          PPDF_trustedNewDoc = app.trustedFunction(function() {

                              try{

                                 // console.println("PATHSS::"app.getPath("app", "javascript"));

                                  app.beginPriv();

                              console.println("New Doc: "+app.newDoc());

                            newDoc = app.newDoc();

                            newDoc.addScript("init", "this.disclosed=true");

                            app.endPriv();

                            return newDoc;

                              }

                              catch(err){

                                  console.println("Error: "+err.message);

                              }

                           

                          });

                           

                          at   newDoc = app.newDoc(); here issue occurring

                           

                           

                          app.addMenuItem({

                            cName: "Assemble Report",

                            cParent: "LynxTools",

                            cExec: "chooseDocumentCode()",

                            cEnable: "event.target != null"

                          });

                           

                          function chooseDocumentCode() {

                            var cResponse = app.response({

                            cQuestion: "Enter the document code",

                            cTitle: "Document Code",

                            cDefault: "",

                            cLabel: "Code:"

                            });

                            if (cResponse != null){

                            assembleReport(cResponse)

                            }

                          }

                          • 10. Re: app.openDoc
                            try67 MVP & Adobe Community Professional

                            Where are you calling this method, exactly?

                            Also, don't do this:

                            console.println("New Doc: "+app.newDoc());

                            You're calling the newDoc method in this line and creating a new document, and then again in the next line... You probably don't want to do that.

                            • 11. Re: app.openDoc
                              rajavardhanr3623689 Level 1

                              In app.menuItems we are calling cExec Method

                              app.addMenuItem({

                                cName: "Assemble Report",

                                cParent: "LynxTools",

                                cExec: "chooseDocumentCode()",

                                cEnable: "event.target != null"

                              });

                               

                              In chooseDocumentCode() Method we are calling assembleReport

                               

                              function chooseDocumentCode() {

                                var cResponse = app.response({

                                cQuestion: "Enter the document code",

                                cTitle: "Document Code",

                                cDefault: "",

                                cLabel: "Code:"

                                });

                                if (cResponse != null){

                                assembleReport(cResponse)

                                }

                              }

                               

                               

                              assembleReport method

                               

                              function assembleReport(documentCode) {

                               

                                console.show();

                                console.clear();

                               

                                allOpenDocs = PPDF_trustedActiveDocs();

                                for (d=0; d < allOpenDocs.length; d++) {

                                if (allOpenDocs[d].documentFileName.indexOf(documentCode) >= 0) {

                                if (allOpenDocs[d].documentFileName.indexOf("Summary") >= 0) {

                                summaryDoc = allOpenDocs[d];

                                PPDF_trustedSaveAs(summaryDoc, summaryDoc.path.split(".pdf")[0]+"_New.pdf");

                                }

                                if (allOpenDocs[d].documentFileName.indexOf("Library") >= 0) {

                               

                                libraryDoc = allOpenDocs[d];

                                digestDoc = PPDF_trustedNewDoc();

                                PPDF_trustedSaveAs(digestDoc, libraryDoc.path.split(".pdf")[0]+"_Digest.pdf");

                                app.openDoc(digestDoc.path);

                                }

                                /*

                                if (allOpenDocs[d].documentFileName.indexOf("Cover") >= 0) {

                                coverDoc = allOpenDocs[d];

                                }

                                */

                               

                               

                                }

                                }

                               

                              here the exactly method is calling ,In this method trusted function I am calling i.e,   digestDoc = PPDF_trustedNewDoc()

                              • 12. Re: app.openDoc
                                try67 MVP & Adobe Community Professional

                                OK, and what's the exact error message you're getting? Remove the try-catch clause, so we can see the full message, please.

                                • 13. Re: app.openDoc
                                  rajavardhanr3623689 Level 1

                                  NotAllowedError: Security settings prevent access to this property or method.

                                  App.newDoc:61:Menu Assemble Report:Exec

                                  • 14. Re: app.openDoc
                                    try67 MVP & Adobe Community Professional

                                    And just to make sure, what application are you running this in?

                                    • 15. Re: app.openDoc
                                      rajavardhanr3623689 Level 1

                                      Acrobat reader DC
                                      we are trying to create a new pdf file with hyperlinks to another pdf

                                      • 16. Re: app.openDoc
                                        try67 MVP & Adobe Community Professional

                                        That should have been my first question... You can't use this method in Reader. Reader can't create new PDF files, nor can it edit existing ones (beyond very basic stuff like adding comments or filling in fields). What you want to do is impossible in Reader.

                                        • 17. Re: app.openDoc
                                          rajavardhanr3623689 Level 1

                                          Thanks Doe,
                                          how we can overcome this issue ,

                                          Is there any possibility to resolve this issue Is  any other versions is available like  acrobat,Pro or etc.

                                          it will be very useful if you could help me out on this issue.

                                           

                                          Thank Q

                                          • 18. Re: app.openDoc
                                            try67 MVP & Adobe Community Professional

                                            "Doe"?

                                             

                                            The solution is to use Acrobat.

                                            • 19. Re: app.openDoc
                                              rajavardhanr3623689 Level 1

                                              Oh... I thought its your name !

                                               

                                              Acrobat ? I dint get you sir, Is there specific version of Acrobat ,Because when i try to download Acrobat its showing different versions
                                              please tell me complete version of Acrobat.

                                              • 20. Re: app.openDoc
                                                Test Screen Name Most Valuable Participant

                                                Free

                                                  Acrobat Reader

                                                Paid for (one time purchase, or subscription. Subscription recommended)

                                                  Acrobat Standard (basic)

                                                  Acrobat Pro (powerful)

                                                 

                                                Important

                                                1. Every user who wants to run this will need their own copy of Acrobat.

                                                2. This is NOT for a server or automatic process.