11 Replies Latest reply on Jul 16, 2015 2:51 AM by Test Screen Name

    How to set a javascript reference to show  different filename using Adobe Acrobat Javascript?

    Alex Doubts Level 1

      How to set a javascript reference to show  different filename using Adobe Acrobat Javascript?

       

      myTrustedBrowseForDoc = app.trustedFunction( function ( oArgs ) { 

               app.beginPriv(); 

                    var myTrustedRetn = app.browseForDoc( oArgs ); 

               app.endPriv(); 

               return myTrustedRetn; 

               } 

          ); 

           

          myTrustedSaveAs = app.trustedFunction( function ( doc, oArgs ) { 

               app.beginPriv(); 

                    var myTrustedRetn = doc.saveAs( oArgs ); 

               app.endPriv(); 

               return myTrustedRetn; 

               } 

          ); 

       

       

       

      The developer guide actually wants you to add this content to the existing "config.js" file. I recommend creating a new file, since its easier to deploy in a network. Either way, every client/user who needs to be able to save documents this way, needs this JavaScript Code in his Application/User-JavaScript-Folder.

       

       

       

      Within the Acrobat Document, which you want to obtain a certain file name, you can now use the trusted functions "myTrustedBrowseForDoc" and "myTrustedSaveAs" to store the file. To call the trusted functions and deliver the file name you can either you use a form field (button) or you add a new menu item. Add the following JavaScript Action to the button/menu item and change "Roller Coaster" to the name of the field which contains the value which you want to become the new file name:

       

       

       

          var fileName = this.getField("Roller Coaster").valueAsString; 

           

          try { 

               var oRetn = myTrustedBrowseForDoc({bSave: true, cFilenameInit: fileName + ".pdf"}); 

               try { 

                    myTrustedSaveAs(this, { cPath: oRetn.cPath, cFS:oRetn.cFS }); 

               } 

               catch(e) { 

                    console.println("Save not allowed, perhaps readonly."); 

               } 

          } 

          catch(e) { 

          console.println("User cancelled Save As dialog box"); 

          } 

       

      With the above option I am able to get different file names in SAVE DIALOG BOX but can't allow Client to put the config.js file in their machines. Is their any option to make the same work without making client to put the JS Script in all machines.