Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Using javascript to save a pdf to a different directory and generating a new filename based on form fields in the document.

$
0
0

I have built the following script in an attempt to create a submit button that will automatically save the document in a different directory on my computer. It will also use the form field data "customer" and "date" to generate the filename. I printed out the variable myPath and it looks like it printed the correct string. I keep getting the following error:

 

TypeError: redeclaration of const path

 

any help would be much appreciated.

 

 

 

 

 

var customer = this.getField("Customer").value;

var date = this.getField("Date").value;

var path = "C:/Users/awilliams/My Documents/Test/"

 

  var reg = date.match(/(\d+)\/(\d+)\/(\d+)/);

 

 

var myPath= "C:/Users/awilliams/My Documents/Test/" + customer + "_" + reg[1] + "." + reg[2] + "." +

reg[3] + ".pdf";

 

 

this.saveAs(myPath);


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>