This one should be simple enough for you Javascript/Extendscript wizards. I want to print a document using a print preset, while also specifying a page range (and maybe other options as well, after having chosen the preset). Consulting the InDesign CS6 JavaScript Scripting Guide it has this wonderful, detailed explanation of how to do it:
Printing with printer presets
To print a document using a printer preset, include the printer preset in the print command.
Wow. So descriptive and helpful. Um, can anyone help me make better sense of this?
Edit (01/21/2019)
I was asked how I was able to tell the script which pages I wanted to print. It turns out that this is not stored in the PrinterPreset
.
Document
has a property called printPreferences
which allows access to the PrintPreference
object. This object allows the developer to set the pageRange
by either specifying a PageRange
enum or a String with the page range (with "1" being the first page).
So, to illustrate:
var document = app.activeDocument; // Presumes the document you want to print is already open.
document.printPreferences.pageRange = PageRange.ALL_PAGES; // Will print all pages in the document.
document.printPreferences.pageRange = "1-3,7,10,12-15" // Prints pages 1, 2, 3, 7, 10, 12, 13, 14, and 15.
Note:
PageRange.SELECTED_ITEMS
seems to only be used for exporting items, not printing (since thePageRange
enum is used for both operations). I have not tested this, however.
There are many other PrintPreference
properties that can be set before document.print()
is called, so it's worth looking them up.