0 Replies Latest reply on Dec 9, 2013 11:40 AM by jonwilks1

    Signed PDF w/ embedded JavaScript - persisting global variable

    jonwilks1

      My goal is to be able to persist a javascript varible within my PDF document. For my example I have created a PDF document using Apache FOP and iText. I have then signed my PDF with a self assigned certifiacte that my machine trusts. I have also embeded the following javascript based on examples in the API documentation here:

       

      http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?&accessible=true
      

       

      global.x; 
      global.setPersistent("x", true);
      
      incrementMyGlobalVar = app.trustedFunction ( function() {
                app.beginPriv();
                if (global.x  === "undefined") {
                                    global.x = 0; 
                          }else {
                                    global.x += 1; 
                          }
                app.endPriv();
      });
      
      app.alert("Hello World! Count is: " + global.x);
      incrementMyGlobalVar();
      app.alert("Hello World! Count is: "  + global.x);
      

       

      my understanding is that I have gained a prevlideged context because my PDF is signed with a trusted cert. Thus referenceing the documentation again the following should be true.

      1. global variables can be defined and accessed in a privileged context

       

      My javascript preferences are set in the following fashion:

      Screen Shot 2013-12-09 at 2.34.09 PM.png

       

      Here is reference to the signature:

      Screen Shot 2013-12-09 at 2.35.36 PM.png

       

       

      I am recieving the following error via the console

      NotAllowedError: Security settings prevent access to this property or method.
      App.trustedFunction:4:Document-Level:0000000000000000
      
      

       

       

      Any help is appreciated.

       

      Thanks,

               Jon