5 Replies Latest reply on Jan 15, 2018 12:30 PM by Thom Parker

    saveAs java function, wont work!

    mariaw72972926 Level 1

      I´m trying to create a java-instruction, that, when I press a button, save the current PDF-form under a nwe name. The name of the PDF will be fetched from a field within the PDF-form.


      BUT - I can´t get the "saveAs" function to work!


      I´m using the Adobe Acrobat Pro DC.


      I want to use the java-command because I need to be able to name the new file from a field in the form.

      I´ve been trying a couple of different syntax:










      I am lead to belive that it is a problem with security, a saveAs or save function might be able to change data on the computer without the users controll. BUT - the command exists - how do I set it up to work?!


      The form will later be mail to different recipients, where I need the same function to work. SO - I can´t place a script in the Java-folder since it won follow the document to the new user?!

        • 1. Re: saveAs java function, wont work!
          Bernd Alheit Adobe Community Professional & MVP

          Read the documentation of the saveAs method.


          Info: Acrobat uses JavaScript, not Java.

          • 2. Re: saveAs java function, wont work!
            mariaw72972926 Level 1

            I have - and it still do not have a solution for this to work. This obiously means that my understanding of what I´m doing isn´t as good as it need to be!


            However - that is why I´m trying to seek some help here...


            1) Is it possible to create a "button", and using Java-code, from the button, to initiate a saveAs command?

            2) If it is - Do I have to do any set-up of the file or program/user to get this function to work? If so - how and where?

            3) I´m going to use this form on both PC and tablet (Android), is it posible?


            4) Where do I go wrong??!?


            I´ve understod from another thread that I need to have a folder level script to automate he saveAs function. But why won´t i start at all? Is there an alternative? It do NOT need the save function to be forced without the users input. It would accually be prefered if the user is informed, and asked, if he accepts the saveas action, - but I need the filename to be suggested, so he/she only need to press yes/no or accept/cancel, or something...


            As I´ve understood the problems lies in this: ...These methods can be executed only in a privileged context, which includes console, batch and application initialization events. All other events (for example, page open and mouse-up events) are considered non-privileged.


            So - how do I run around/solve this problem?


            • I need to have a Save/saveAs function
            • I need it to be executed/initialized by a mouse-up event, the same event that will mail the document to a recipient.
            • I need to be able to suggest the file-name
            • I can´t place a folder level scripts on ALL the recipients computers/tablets
            • I need it to work on PC and Android
            • It should be executed just before I e-mail the document to a recipient, because I need to change the name of the document I e-mail, AND because I want to save a copy of the sent file in/on my computer/tablet.
            • 4. Re: saveAs java function, wont work!
              Test Screen Name Most Valuable Participant

              It’s JavaScript not Java!! This is never abbreviated to Java because Java is different.


              Info: nothing will work in Android. Savingvisnt even a concept. 

              • 5. Re: saveAs java function, wont work!
                Thom Parker Adobe Community Professional
                1 person found this helpful