The app.print()
method can take a PrinterPreset
object as one of it's arguments. Here's a link to a reference of the method for more information.
Here's an example (untested):
var doc = app.activeDocument;
var file = File(doc.fullName); // Get the active document's file object
var preset = app.printerPresets[0]; // Use your printer preset object
app.print(file, null, preset);
The InDesign reference lists the app.print()
method more or less like this:
void print (from: varies[, printDialog: bool][, using: varies])
Prints the specified file(s).
Parameter Type Description
from Array of Files One or more file paths. Can accept: File or Array of Files.
File
printDialog bool Whether to invoke the print dialog (Optional)
using PrinterPreset Printer preset to use. Can accept: PrinterPresetTypes enumerator or PrinterPreset. (Optional)
PrinterPresetTypes
The first information listed is the return value of the method, void
, in this case which means it doesn't return anything.
The next information listed is the name of the method print
followed by it's named parameters: from
, printDialog
, and using
as well as what each parameter type should be.
The parameters are also listed in the chart for further explanation. The from
parameter expects an object of type File
for example. So, in the example above, I make an "instance" of a File
object by calling it's constructor: var file = File(doc.fullName);
. Then I get an already existing PrinterPreset
object: var preset = app.printerPresets[0];
. Finally, I pass each object to the function inserting null
for the middle variable (since it's optional, I just decide to ignore it): app.print(file, null, preset);
.