Copy link to clipboard
Copied
Hi,
I would like to use some field values to generate a default pdf name when I click on a button with the saveas method.
Here is whay I did but does not work:
*********************************************************************
var pp = this.getPrintParams();
var printRange = [];
var name = +this.getField("Nom_Prof_T").valueAsString +"_" +this.getField("Assignatura_T").valueAsString +"_" +this.getField("Curs_Trim_T").valueAsString +".pdf";
printRange.push([0,0]); // print page 1
printRange.push([2,3]); // print page 3 and 4
pp.pageHandling = 3;
pp.printRange = printRange;
nUpAutoRotate = true;
nUpNumPagesH = printRange;
this.print(pp);
this.saveAs(name);
*********************************************************************
I store the pdf name in the name variable dna I want to use it as default "saveas" name. What I'm doing wrong???
Thanks
You can't specify the file-path of the saved file if you run the script from an unprivileged context, such as a button in the file itself. Doing that requires creating a trusted function in a folder-level script (a .js file installed on the local computer, basically), and then calling that function from your code. Alternatively, you can display the desired file name to the user in an alert window and ask them to copy it and use it in the Save As dialog, but you can't enforce it.
Copy link to clipboard
Copied
You can't specify the file-path of the saved file if you run the script from an unprivileged context, such as a button in the file itself. Doing that requires creating a trusted function in a folder-level script (a .js file installed on the local computer, basically), and then calling that function from your code. Alternatively, you can display the desired file name to the user in an alert window and ask them to copy it and use it in the Save As dialog, but you can't enforce it.
Copy link to clipboard
Copied
ok, thanks for your response