Package com.deltawalker.script
Interface PrinterSettings
public interface PrinterSettings
The printer settings used when printing comparisons: the printer, number
of copies, page range, duplex mode and printing to a file. Obtained with
App.getSettings().getPrinter().
const printer = App.getSettings().getPrinter();
console.log('Installed printers: ' + printer.getInstalledPrinters().length);
// Print to a PDF file (macOS only)
printer.setPrintToFile(true);
printer.setFilePath(App.getProperty('user.home') + '/comparison.pdf');
await comp.print();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAnswers whether printed copies are collated.intReturns the number of copies to print.Returns the duplex mode - single-sided or double-sided printing - for printers that support it.intReturns the last page to print when printing a range of pages (PrintScope.PAGE_RANGE).Returns the full path of the file to print to.String[]Returns the names of all printers installed on this computer.Returns the printer driver.Returns the name of the printer used for printing.booleanAnswers whether printing goes to a file instead of a printer.getScope()Returns which pages are printed: all pages or a range of pages.intReturns the first page to print when printing a range of pages (PrintScope.PAGE_RANGE).voidsetCollate(boolean collate) Sets whether printed copies are collated.voidsetCopyCount(int copyCount) Sets the number of copies to print.voidsetDuplexMode(DuplexMode duplexMode) Sets the duplex mode, for printers that support it.voidsetEndPage(int endPage) Sets the last page to print when printing a range of pages (PrintScope.PAGE_RANGE).voidsetFilePath(String name) Sets the full path of the PDF file to print to.voidsetPrinterDriver(String driver) Sets the printer driver to use for printing: On macOS, the destination type ("Printer", "Fax", "File", or "Preview"). On Windows, the name of the driver (often "winspool"). On Linux (GTK), the backend type name, for example "GtkPrintBackendCups".voidsetPrinterName(String name) Sets the name of the printer to use for printing: the printer name on macOS and Linux, the device name on Windows.voidsetPrintToFile(boolean printToFile) Sets whether printing goes to a PDF file, set withsetFilePath(String), instead of a printer.voidsetScope(PrintScope scope) Sets which pages are printed: all pages or a range of pages.voidsetStartPage(int startPage) Sets the first page to print when printing a range of pages (PrintScope.PAGE_RANGE).
-
Method Details
-
getCollate
boolean getCollate()Answers whether printed copies are collated.- Returns:
trueif copies are collated,falseotherwise- Since:
- 2.0
- See Also:
-
getCopyCount
int getCopyCount()Returns the number of copies to print.- Returns:
- the number of copies
- Since:
- 2.0
- See Also:
-
getDuplexMode
DuplexMode getDuplexMode()Returns the duplex mode - single-sided or double-sided printing - for printers that support it.- Returns:
- the duplex mode; never
null - Since:
- 2.0
- See Also:
-
getEndPage
int getEndPage()Returns the last page to print when printing a range of pages (PrintScope.PAGE_RANGE).- Returns:
- the 1-based number of the last page
- Since:
- 2.0
-
getFilePath
String getFilePath()Returns the full path of the file to print to. Used only whengetPrintToFile()returnstrue.- Returns:
- the path of the file to print to
- Since:
- 2.0
-
getInstalledPrinters
String[] getInstalledPrinters()Returns the names of all printers installed on this computer.- Returns:
- an array with the names of the installed printers; empty when there are none
- Since:
- 2.0
-
getPrinterDriver
String getPrinterDriver()Returns the printer driver.- Returns:
- the printer driver
- Since:
- 2.0
- See Also:
-
getPrinterName
String getPrinterName()Returns the name of the printer used for printing.- Returns:
- the printer name
- Since:
- 2.0
-
getPrintToFile
boolean getPrintToFile()Answers whether printing goes to a file instead of a printer.- Returns:
trueto print to a file,falseotherwise- Since:
- 2.0
-
getScope
PrintScope getScope()Returns which pages are printed: all pages or a range of pages.- Returns:
- the print scope; never
null - Since:
- 2.0
- See Also:
-
getStartPage
int getStartPage()Returns the first page to print when printing a range of pages (PrintScope.PAGE_RANGE).- Returns:
- the 1-based number of the first page
- Since:
- 2.0
-
setCollate
void setCollate(boolean collate) Sets whether printed copies are collated.This setting may be controlled by the printer driver: if the printer collates by itself, the value of this setting may always be
false.- Parameters:
collate-trueto collate copies,falsenot to- Since:
- 2.0
-
setCopyCount
void setCopyCount(int copyCount) Sets the number of copies to print.This setting may be controlled by the printer driver: if the printer prints multiple copies by itself, the value of this setting may always be 1.
- Parameters:
copyCount- the number of copies; at least 1- Throws:
IllegalArgumentException- ifcopyCountis less than 1.- Since:
- 2.0
- See Also:
-
setDuplexMode
Sets the duplex mode, for printers that support it.- Parameters:
duplexMode- the duplex mode; cannot benull- Throws:
NullPointerException- ifduplexModeisnull- Since:
- 2.0
- See Also:
-
setEndPage
void setEndPage(int endPage) Sets the last page to print when printing a range of pages (PrintScope.PAGE_RANGE).- Parameters:
endPage- the 1-based number of the last page- Throws:
IllegalArgumentException- ifendPageis less than 1- Since:
- 2.0
-
setFilePath
Sets the full path of the PDF file to print to. Used only whengetPrintToFile()returnstrue.Printing to a PDF file is available on macOS only.
- Parameters:
name- the full path of the PDF file; cannot benullor empty- Throws:
UnsupportedOperationException- when called on an operating system other than macOSNullPointerException- ifnameisnullIllegalArgumentException- ifnameis empty- Since:
- 2.0
-
setPrinterDriver
Sets the printer driver to use for printing:- On macOS, the destination type ("Printer", "Fax", "File", or "Preview").
- On Windows, the name of the driver (often "winspool").
- On Linux (GTK), the backend type name, for example "GtkPrintBackendCups".
- Parameters:
driver- the printer driver; cannot benullor empty- Throws:
NullPointerException- ifdriverisnullIllegalArgumentException- ifdriveris empty- Since:
- 2.0
-
setPrinterName
Sets the name of the printer to use for printing: the printer name on macOS and Linux, the device name on Windows. The names of the installed printers are returned bygetInstalledPrinters().- Parameters:
name- the printer name; cannot benullor empty- Throws:
NullPointerException- ifnameis nullIllegalArgumentException- ifnameis empty- Since:
- 2.0
-
setPrintToFile
Sets whether printing goes to a PDF file, set withsetFilePath(String), instead of a printer.Printing to a PDF file is available on macOS only.
- Parameters:
printToFile-trueto print to a file,falseto print to a printer- Throws:
UnsupportedOperationException- when called on an operating system other than macOS- Since:
- 2.0
-
setScope
Sets which pages are printed: all pages or a range of pages.- Parameters:
scope- the pages to print; cannot benull- Throws:
NullPointerException- ifscopeis null- Since:
- 2.0
- See Also:
-
setStartPage
void setStartPage(int startPage) Sets the first page to print when printing a range of pages (PrintScope.PAGE_RANGE).- Parameters:
startPage- the 1-based number of the first page- Throws:
IllegalArgumentException- ifstartPageis less than 1- Since:
- 2.0
-