Copy link to clipboard
Copied
// get the value of the form field var text1Value = this.getField("OrderNumber").value;
// here you need to make sure that no illegal characters are used, and also that text1Value is not empty
// make a file name from the field value var newFileName = text1Value + ".pdf";
// get the path where the file is currently located var filePath = this.path.replace(this.documentFileName);
// create the new full path var newFullFilePath = filePath + newFileName; try { this.saveAs(newFullFilePath);
// Only this will not work from a button... } catch (e) { app.alert("Error! Could not save as: " + newFullFilePath); }
Copy link to clipboard
Copied
- Post the code with normal formatting.
- Drop the try-catch clause and report the full text of the exception.
Copy link to clipboard
Copied
Also, we told you already you can't do it without a script that's installed on the local machine. You're wasting your time.
Copy link to clipboard
Copied
I Instated java in my machine properly.
Copy link to clipboard
Copied
Java is not JavaScript, and vice-versa.
Copy link to clipboard
Copied
This line:
var filePath = this.path.replace(this.documentFileName);
would makes sense if you were to change it to this:
var filePath = this.path.replace(this.documentFileName, "");
Copy link to clipboard
Copied
You might want to look at How to Save a PDF with Acrobat JavaScript by Thom Parker from 2010. Quite old but the script still works as written, you just have to adjust for the revisions in the location of the user Acrobat JavaScript folder if you use the user's folder.
Unlike a executable line of code that end with a semi colon, comments only end with a new line. You posted code will not work without some editing.
The trusted function was introduced in Acrobat 7.0.