2 Replies Latest reply on Nov 11, 2015 11:20 AM by Karl Heinz Kremer

    error: doc.saveAs is not a function

    michel jv71650061

      Acrobat DC


      File: MyTrustedSaveAs.js


      contents of this file:


      myGetPath = app.trustPropagatorFunction(function(v1,v2){


      return app.getPath(v1,v2);



      myTrustedGetPath = app.trustedFunction(function(v1,v2) {


      return myGetPath(v1,v2);




      safeSaveAs = app.trustPropagatorFunction(function(doc,vPath){





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








      call from a mouse-up in a form: 


      var d = getField("DATE").valueAsString;

      var f = getField("Name").valueAsString;


      // Specify the folder 

      var fldr = "/c:/presort/"; 


      // Determine the full path 

      var fp = fldr + d + f; 


      // Save the file 



      I receive the error:


      doc.saveAs is not a function



        • 1. Re: error: doc.saveAs is not a function
          Bernd Alheit Adobe Community Professional & MVP

          This is correct. The function saveAs is not defined for a string.


          You must use the parameter doc and vPath.

          • 2. Re: error: doc.saveAs is not a function
            Karl Heinz Kremer Adobe Community Professional

            This is basic Javascript, and has nothing to do with how JavaScript is implemented in Acrobat. You may want to get a good tutorial about the core JavaScript language and read up on how functions need to be called. When you look at how the function myTrustedSaveAs() is defined, you will find this:


            myTrustedSaveAs = app.trustedFunction(function(doc,vPath){
            // ....

            This shows that you need two parameters: One called "doc", and one called "vPath" - you are only providing one (the path). So, change your function call to this, and it should work:


            myTrustedSaveAs(this, fp); 


            "this" - in the context of a button event handler - will refer to the current document.