Skip to main content
mdn61371708
Participant
September 24, 2018
Question

Use this Scrip in button , Its says error please help

  • September 24, 2018
  • 3 replies
  • 682 views

// 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); }

This topic has been closed for replies.

3 replies

Inspiring
September 25, 2018

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.

doc.saveAs()

The trusted function was introduced in Acrobat 7.0.

Inspiring
September 24, 2018

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, "");

try67
Community Expert
Community Expert
September 24, 2018

- Post the code with normal formatting.

- Drop the try-catch clause and report the full text of the exception.

try67
Community Expert
Community Expert
September 24, 2018

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.

mdn61371708
Participant
September 24, 2018

I Instated java in my machine properly.