Acrobat print automation with printParams set conditionally
Hello,
I am new to Acrobat JS and automation field and am trying to automate some tasks in the given sequence using JS and Action wizard, that doesn't require user interaction.
1. Print to PDF
2. Encrypt
3. Save
I am having trouble in the print to PDF step. I want to Print all pdfs in a given folder to its subfolder named "Print", and name the printed files dynamically as well.
I also want to set some of the printParams dynamically based on filename of pdf, to be specific, I want some of the pdfs to be printed using one color profile, and the others using a different color profile.
For example, I have two pdf forms with file names, "Year" and "Quarter".
When I run the action, I want the script to check the filename, in a given switch/if condition, and if it matches "Quarter" file name condition,
I want to run a loop, that changes one of the check box values in that form, prints it using a specific (within condition)hardcoded color profile, and repeats the task until all four(quarter) check boxes have been printed to separate files with filenames of printed files set based on the checkbox that was marked.
But if the "Year" file name condition is met, I want it to print the file with the same name in "Print" subfolder, with a specific different color profile, also hardcoded within condition.
I've exhausted online resources as best as I could, used Acrobat SDK and JS API references to look for something useful but haven't been successful.
Any help or guidance would be appreciated.
The code I came up with is as follows:
When trying to save it an "execute javascript" action step, it gives following error
SyntaxError: illegal character
10: at Line 11
var pp = this.getPrintParams()
pp.interactive = pp.constants.interactionLevel.automatic;
pp.printerName = "Adobe PDF"
var d = app.activeDocs;
for (var i=0; i < d.length; i++)
switch(d[i].info.Title){
case "Quarter":
for(i=1 ; i!=4 ; i++)
this.getField("Quarters").value = `Q${i}`;
pp.colorProfile = "Dot Gain 15%"
this.print(pp)
break;
case "Year":
pp.colorProfile = "Gray Gamma 1.8"
this.print(pp)
break;
default:
this.print(pp)
break;
}
