Class Printer
NativeWindow.printer().
window.printer().print(invoice, "Invoice 0091")
.thenAccept(result -> status.setText(result.toString()));
The dialog is the system's: it chooses the printer, the copies, the pages and the paper, and
it may save the job as PDF where the system offers that. While it is open the window waits and
the UI thread does not. A document Limn lays out is printed by limn.print.Document#print,
which writes its PDF and comes here; a PDF the application already has (one it received, one it
saved earlier) is printed by the calls below without a document.
The system scales a page to the printer's paper when the two differ, and never up; it does not lay the document out again.
Each call returns at once and completes on the UI thread. It throws for a null, a blank title
and off the UI thread, as the rest of the window's API does, at the call and before anything is
read, and never for what the PDF holds: a file that cannot be read, or a system that refuses the
bytes, completes with PrintResult.FAILED and a WARNING saying why.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PrinterThe printer of a window with no printing under it: every call answersPrintResult.UNAVAILABLE. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether a print can be asked under this window, answered without asking anything: an application greys out its "Print…" when it is false.Prints a PDF held in memory through the system's dialog.Prints a PDF file through the system's dialog.Prints a job, the form a document laid out by Limn uses: it knows its paper, which the system's dialog then starts from.
-
Field Details
-
NONE
The printer of a window with no printing under it: every call answersPrintResult.UNAVAILABLE.
-
-
Constructor Details
-
Printer
- Parameters:
peer- what the window's backend asks the system through
-
-
Method Details
-
isAvailable
public boolean isAvailable()Whether a print can be asked under this window, answered without asking anything: an application greys out its "Print…" when it is false. Saving a document as PDF never depends on it.- Returns:
- false for a window with no desktop under it, and for a Linux desktop with no print portal
-
print
Prints a PDF file through the system's dialog.- Parameters:
pdf- the file; read on a thread of its owntitle- the job's name in the system's queue; never blank- Returns:
- what became of it, completed on the UI thread
- Throws:
IllegalArgumentException- iftitleis blank, here, before the file is read
-
print
Prints a PDF held in memory through the system's dialog.- Parameters:
pdf- a complete PDF file; not copied, and not to be changed until the stage completestitle- the job's name in the system's queue; never blank- Returns:
- what became of it, completed on the UI thread
- Throws:
IllegalArgumentException- iftitleis blank
-
print
Prints a job, the form a document laid out by Limn uses: it knows its paper, which the system's dialog then starts from.- Parameters:
job- what to print- Returns:
- what became of it, completed on the UI thread
-