0

I am trying to use the following script to save my pdf document to a specific location:

this.saveAs("C:/Users/logan/Desktop/test.pdf");

This script is saved in a folder level .js file, inside an app.beginPriv/app.endPriv block.

Each time I try to run the script I receive the following error:

TypeError: this.saveAs is not a function

I know the script is being accessed, because if I change the script to display a simple popup the script will run fine. I believe this is likely due to the engine that is processing my script (I am accessing the code from Bluebeam, not Acrobat).

If this is the problem, I need to know what the equivalent operator would be in the Bluebeam engine to perform the save as process, but unfortunately there is no such reference online, and the tech support for the software isn't permitted to offer advise for coding.

So my question is: Is there another possible reason for my script not working, other than it not being recognized by the engine? If it is an issue with the engine, does anyone have any advise at all for how to seek out the line of script I need?

Thank you in advance for your help!

whoosis
  • 454
  • 7
  • 25
Logan
  • 41
  • 1
  • 6
  • 1
    Javascript can't save directly to the server for security reasons. You have to invoke a server side language. There are several articles in Stackoverflow dealing with this. Here is one. http://stackoverflow.com/questions/7165395/call-php-function-from-javascript Just google javascript save pdf to server and you'll find lots of info. – Mark Bellamy Mar 08 '17 at 23:08
  • 1
    The situation describe in the OP has nothing to do with a server/client environment; this advice is therefore misleading. – Max Wyss Mar 09 '17 at 09:43

1 Answers1

0

You should put that line of code into a function which you then make privileged. Then call that function instead of the plain saveAs().

This would work in Acrobat; I don't know enough about Bluebeam to determine whether it does too; you might contact Bluebeam support for an authorative answer.

Max Wyss
  • 3,549
  • 2
  • 20
  • 26
  • Thank you for the quick response. I am actually calling the script in the console, it runs through the script until it reaches the saveAs() function and then gives me the error. The following is what I have in my folder: mySaveAs = app.trustPropagatorFunction(function(doc,path) { app.beginPriv(); doc.saveAs(path); app.endPriv(); }) myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path) { app.beginPriv(); mySaveAs(doc,path); app.endPriv(); }); Then in the console I call the function:: myTrustedSpecialTaskFunc(this, "C:/Temp"); Any further insight? Thanks – Logan Mar 09 '17 at 15:09
  • I'm at a loss on this one. From my understanding, I am calling the script from inside a trusted function and so it should be working. Does anyone see a reason why the script shown in the comment above is not working? – Logan May 09 '17 at 17:42