Use this Scrip in button , Its says error please help

Sep 24, 2018

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

146

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Use this Scrip in button , Its says error please help

Sep 24, 2018

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

147

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 24, 2018 0
Most Valuable Participant ,
Sep 24, 2018

Copy link to clipboard

Copied

- Post the code with normal formatting.

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2018 0
Most Valuable Participant ,
Sep 24, 2018

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2018 2
Sep 24, 2018

Copy link to clipboard

Copied

I Instated java in my machine properly.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2018 0
Adobe Community Professional ,
Sep 24, 2018

Copy link to clipboard

Copied

Java is not JavaScript, and vice-versa.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2018 0
Adobe Community Professional ,
Sep 24, 2018

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 24, 2018 1
Adobe Community Professional ,
Sep 25, 2018

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.

doc.saveAs()

The trusted function was introduced in Acrobat 7.0.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 25, 2018 0