5 Replies Latest reply on May 11, 2017 3:05 PM by testt70366819

    Save Document to network drive using button action

    Redbeard77753

      I am attempting to save a document to a network drive using a button action. I am using Acrobat 8 Pro. I have a script that is saving to the C: drive and it is working fine.

       

      Folder level Script

      var mySaveAs = app.trustedFunction( function(oDoc,cPath) {

          app.beginPriv();

          try {

              oDoc.saveAs(cPath);

          } catch(e){

              app.alert("Error During Save");

          }

          app.endPriv();

      });

       

      Document Level SCript

      var filePath = this.path.replace(this.documentFileName, "");

      var newFileName = this.getField("Mlastname").valueAsString + " " + this.getField("Mfirstname").valueAsString + " PcDec.pdf";

      mySaveAs(this, filePath+newFileName);

       

      The IT deparment would like it to go to the H: drive. Can I make adjustments to this set of scripts or do I need to start from the begining.

      I have limited experience with JavaScript.

        • 1. Re: Save Document to network drive using button action
          try67 MVP & Adobe Community Professional

          You can use the following command instead of what you have:

           

          var filePath = "/h/";

          var newFileName = this.getField("Mlastname").valueAsString + " " + this.getField("Mfirstname").valueAsString + " PcDec.pdf";

          mySaveAs(this, filePath+newFileName);

          • 2. Re: Save Document to network drive using button action
            Redbeard77753 Level 1

            Works perfect thank you for the help.

            • 3. Re: Save Document to network drive using button action
              testt70366819 Level 1

              Where put you the Folder Level Script and where did you put the Document Level Script ?

              I get the error message "UnsupportValueError : Value is unsupported. Parameter cPath

               

              The Document Level Script I put in the Text Value - Calculate tab in de stamp pdf.
              Is that correct ?

              • 4. Re: Save Document to network drive using button action
                Bernd Alheit Adobe Community Professional & MVP

                You should add the code to a form button.

                • 5. Re: Save Document to network drive using button action
                  testt70366819 Level 1

                  Hi,

                   

                  I've created a dynamic stamp where the user has to fill in some information.
                  Information like invoice number, Cost Center, filename, supplier, company....

                   

                  The first question is : I want to save the document with the filename the user has filled in.

                  How can I do that ?

                   

                  The second question is : I want to save the document in the "company" directory.

                  He has to choose the company from dropdown (in the stamp). So, I want to save the document in the "company" directory.

                  The user has 3 "company's" possibilities A, B or C. When he choose for ex B then the document has to be saved in the B map.

                   

                  And the last question is : He also has to choose if the document is invoice or document. If it's a document then under the company (choose by stamp) under documents map. Else under company invoice map.

                   

                   

                  mySaveAs.js file (located in the map program files"

                   

                  var mySaveAs = app.trustedFunction(

                  function(oDoc,cPath,cFlName)

                  {

                  app.beginPriv();

                  // Ensure path has trailing "/"

                  //cPath = cPath.replace(/([^\/])$/, "$1/");

                  cPath = "/c/temp/";

                  try{

                  oDoc.saveAs(cPath + cFlName);

                  }catch(e){

                  app.alert("Error During Save  " +e);

                  }

                  app.endPriv();

                  });

                   

                  Is this file correct ?

                   

                  What and where do I have to fill in the code in the stamp under the "save" text field - calculate - custom calculation script.

                  (because when I put a button I don't see that button.

                   

                  Using Adobe XI

                   

                  PS : I figurerd out that I can do a save as but it's the  stamp file. And not the document with a stamp.
                  And when you put the OK button in the stamp document and you run it then you see the button but it doesn't work.
                  You can choose for mouse up, mouse down, mouse click, ...
                  But non of them work.

                   

                  Thanks