use of qz.exception.NullPrintServiceException in project tray by qzind.
the class PrintRaw method printToPrinter.
/**
* Constructs a {@code SimpleDoc} with the {@code commands} byte array.
*/
private void printToPrinter(PrintService service, byte[] cmds, PrintOptions.Raw rawOpts) throws PrintException {
if (service == null) {
throw new NullPrintServiceException("Service cannot be null");
}
if (cmds == null || cmds.length == 0) {
throw new NullCommandException("No commands found to send to the printer");
}
SimpleDoc doc = new SimpleDoc(cmds, DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(new JobName(rawOpts.getJobName(Constants.RAW_PRINT), Locale.getDefault()));
DocPrintJob printJob = service.createPrintJob();
waitForPrint(printJob, doc, attributes);
}
Aggregations