How to Save a .pdf document using Javascript

2019-09-18 16:59发布

问题:

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!

回答1:

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.