I am finding myself running into a brick wall and it is upsetting me greatly. It's a problem with setting the printPreferences for a document. Here is the code I have:
with(document.printPreferences) {
activePrinterPreset = outputPreset;
pageRange = outputRange;
for (var j = 0; j < allInks.length; j++) {
document.inks.item(allInks[j]).printInk = false;
}
for (var k = 0; k < printInks.length; k++) {
if (printInks[k].toString() === "Black") {
$.writeln("Found Black!");
printBlack = true;
$.writeln("Set Black!");
} else {
document.inks.item(printInks[k]).printInk = true;
}
}
if (offsetJob) {
// If it's an offset job, we might need to change page sizes.
if (productType === "HI-N13W") {
paperSize = PaperSizes.custom;
paperHeight = 12.5;
paperWidth = 8.5;
} else if (productType.subString(3,5) === "PC") {
paperSize = PaperSizes.custom;
paperHeight = 8;
paperWidth = 12.5;
} else if (couldBeBothJobs.toString().indexOf(productType.subString(3,5)) > -1) {
paperSize = "US Letter";
} else {
paperSize = PaperSizes.custom;
paperHeight = 8;
paperWidth = 25;
}
}
}
In the first FOR loop, you'll see that I have first turned off ALL of the inks in the document for printing. I then only turn on the ones in the "printInks" array in the second FOR loop. If, however, the word "Black" exists in the array, there isn't an Ink for it, so instead, I want to set the built-in printPreference "printBlack". (Which complements the other three—printCyan, printMagenta, and printYellow.)
It's just supposed to be a boolean value, according to the InDesign CS6 Object Model Reference. However, whenever the script gets to that point, it halts. Pasting just that small bit of code to a fresh document, just so I can see the error message, gets me this:
The property is not applicable in the current state.
Huh? What does this mean? And more importantly, how can I fix it? I know that trapping has to be off before this property can be set, but I've definitely made sure that it is off. Can anyone please help?