use of qz.printer.PrintOutput in project tray by qzind.
the class PrintingUtilities method processPrintRequest.
/**
* Determine print variables and send data to printer
*
* @param session WebSocket session
* @param UID ID of call from web API
* @param params Params of call from web API
*/
public static void processPrintRequest(Session session, String UID, JSONObject params) throws JSONException {
Format format = getPrintFormat(params.getJSONArray("data"));
PrintProcessor processor = PrintingUtilities.getPrintProcessor(format);
log.debug("Using {} to print", processor.getClass().getName());
try {
PrintOutput output = new PrintOutput(params.optJSONObject("printer"));
PrintOptions options = new PrintOptions(params.optJSONObject("options"), output, format);
processor.parseData(params.getJSONArray("data"), options);
processor.print(output, options);
log.info("Printing complete");
PrintSocketClient.sendResult(session, UID, null);
} catch (PrinterAbortException e) {
log.warn("Printing cancelled");
PrintSocketClient.sendError(session, UID, "Printing cancelled");
} catch (Exception e) {
log.error("Failed to print", e);
PrintSocketClient.sendError(session, UID, e);
} finally {
PrintingUtilities.releasePrintProcessor(processor);
}
}
Aggregations