Skip to main content
Participating Frequently
April 26, 2018
Answered

how to save as pdf form using script ?

  • April 26, 2018
  • 1 reply
  • 12762 views

i'm using adobe acrobat XI
i want to make a button that can save as the pdf file to local disk such as "D:/test/testing.pdf"

i want to do it using a script


i already look at this website : https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

but my button did not work, i don't know why

the code i'm using are :

this.saveAs("/d/test/testing.pdf");

and

this.saveAs("/d/test/" + this.documentFileName);

and this one got an error message when i use it

// Split Path into an array so it is easy to work with

var aMyPath = this.path.split("/);

// Remove old file name

aMyPath.pop();

// Add new file name

aMyPath.push("NewFileName.pdf");

// Put path back together and save

this.saveAs(aMyPath.join("/"));

i hope a response for this question

thanks for all your help

This topic has been closed for replies.
Correct answer Bernd Alheit

so this code is in the trusted one :

// Split Path into an array so it is easy to work with

var aMyPath = this.path.split("/);

// Remove old file name

aMyPath.pop();

// Add new file name

aMyPath.push("NewFileName.pdf");

// Put path back together and save

this.saveAs(aMyPath.join("/"));​

and this code is in the javascript button :

mySaveAs(this, "/d/test/", this.documentFileName);

is it correct mr bernd ?

thanks for your help


Use the trusted function on this site:

https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javasc…

1 reply

Bernd Alheit
Community Expert
Community Expert
April 26, 2018

You must use a trusted function.

Participating Frequently
April 26, 2018

hello mr bernd

how to use trusted function ?

i never used it before
i've already read several article about trusted function but i not understand yet which code that should i put in the trusted one and which code that i should put in my javascript button function

thanks for your help

Participating Frequently
April 26, 2018

Install the trusted function and use in the button:

mySaveAs(this, "/d/test/", this.documentFileName);


so this code is in the trusted one :

// Split Path into an array so it is easy to work with

var aMyPath = this.path.split("/);

// Remove old file name

aMyPath.pop();

// Add new file name

aMyPath.push("NewFileName.pdf");

// Put path back together and save

this.saveAs(aMyPath.join("/"));​

and this code is in the javascript button :

mySaveAs(this, "/d/test/", this.documentFileName);

is it correct mr bernd ?

thanks for your help