public class GUIPrinterStreamSupport
extends java.lang.Object
The expected flow of the print outputs in the Web GUI driver is as follows.
1. OUTPUT TO PRINTER... PUT... and stream close creates PDF output data
2. The data is delivered to the driver with
GuiDriver.deliverDocumentOutput(Consumer, Runnable, MediaType)
.
3. The driver stores the delivered PDF data with
GuiWebDriver.enqueueDocumentOutput(String, DocumentOutput)
.
4. The driver notifies the JS client with MSG_OPEN_MIME_RESOURCE web socket message.
5. JS client reads the print output id, constructs the print output URL with the id from
the message and opens new browser window pointing it to the URL.
6. DocumentOutputHandler
catches the request, it calls
GuiWebDriver.dequeueDocumentOutput(String)
and serves the PDF data to the JS client.
When there is any error during this step (for example an intermittent network error)
the handler returns the PDF output to the storage with
GuiWebDriver.enqueueDocumentOutput(String, DocumentOutput)
.
Modifier and Type | Class and Description |
---|---|
private class |
GUIPrinterStreamSupport.PrinterStream
The actual printer stream implementation.
|
Modifier and Type | Field and Description |
---|---|
private org.apache.pdfbox.pdmodel.PDPageContentStream |
curContent
Current PDF content stream
|
private java.lang.StringBuilder |
curLine
Current output line
|
private org.apache.pdfbox.pdmodel.PDPage |
currPage
Current PDF page object
|
private org.apache.pdfbox.pdmodel.PDDocument |
doc
The PDF document object
|
private org.apache.pdfbox.pdmodel.font.PDFont |
font
The effective PDFBox font
|
private int |
fontNum
The font passed to OUTPUT TO PRINTER
|
private float |
fontSize
The effective font size
|
private static float |
LINE_SPACING
The PDF user-space line height
|
private static java.util.logging.Logger |
LOG
Logger
|
private PrintOptions |
options
The print options in effect
|
private PDFPageSetup |
pageSetup
The page setup in effect
|
private java.lang.String |
printerName
Printer name passed to OUTPUT TO PRINTER, currently not used
|
private GUIPrinterStreamSupport.PrinterStream |
printerStream
The actual printer stream
|
private float |
startX |
private float |
startY |
Modifier | Constructor and Description |
---|---|
private |
GUIPrinterStreamSupport(java.lang.String printerName,
PrintOptions options)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
Stream |
asStream()
Returns an instance of
Stream that provides the printer output. |
private void |
closePage()
Closes current page in the PDF document.
|
private void |
closeStream()
Closes the stream.
|
private void |
flushLine(boolean addNewline)
Renders a single line to the PDF document and optionally breaks to a new line.
|
private void |
init()
Initializes the instance.
|
private void |
openPage()
Opens new page in the PDF document.
|
static int |
openPrinterStream(java.lang.String printer,
StreamDaemon sd,
PrintOptions options)
Opens a printer stream and returns its remote id.
|
private static final java.util.logging.Logger LOG
private static final float LINE_SPACING
private final PrintOptions options
private final java.lang.String printerName
private int fontNum
private org.apache.pdfbox.pdmodel.font.PDFont font
private float fontSize
private java.lang.StringBuilder curLine
private PDFPageSetup pageSetup
private org.apache.pdfbox.pdmodel.PDDocument doc
private org.apache.pdfbox.pdmodel.PDPage currPage
private org.apache.pdfbox.pdmodel.PDPageContentStream curContent
private float startX
private float startY
private GUIPrinterStreamSupport.PrinterStream printerStream
private GUIPrinterStreamSupport(java.lang.String printerName, PrintOptions options)
printerName
- Printer name.options
- Print options.public static int openPrinterStream(java.lang.String printer, StreamDaemon sd, PrintOptions options)
printer
- Printer name.sd
- Stream daemon instance.options
- Effective print options.public Stream asStream()
Stream
that provides the printer output.private void init()
private void flushLine(boolean addNewline)
addNewline
- When true
new line is added after the line is rendered to the PDF document.private void openPage()
private void closePage()
private void closeStream()