List of usage examples for javax.print PrintService isDocFlavorSupported
public boolean isDocFlavorSupported(DocFlavor flavor);
From source file:org.pentaho.reporting.engine.classic.extensions.modules.java14print.Java14PrintUtil.java
public static void printDirectly(final MasterReport report, PrintService printService) throws PrintException, ReportProcessingException { // with that method we do not use the PrintService UI .. // it is up to the user to supply a valid print service that // supports the Pageable printing. if (printService == null) { printService = lookupPrintService(); } else {//from w ww .j av a 2 s . com if (printService.isDocFlavorSupported(DocFlavor.SERVICE_FORMATTED.PAGEABLE) == false) { throw new PrintException("The print service implementation does not support the Pageable Flavor."); } } PrintRequestAttributeSet attributes = Java14PrintUtil.copyConfiguration(null, report); attributes = Java14PrintUtil.copyAuxillaryAttributes(attributes, report); final PrintReportProcessor reportPane = new PrintReportProcessor(report); final DocPrintJob job = printService.createPrintJob(); final SimpleDoc document = new SimpleDoc(reportPane, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); try { job.print(document, attributes); } finally { reportPane.close(); } }
From source file:org.pentaho.reporting.engine.classic.extensions.modules.java14print.Java14PrintUtil.java
private static PrintService lookupPrintService() throws PrintException { final PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); if (defaultService != null && defaultService.isDocFlavorSupported(DocFlavor.SERVICE_FORMATTED.PAGEABLE)) { return defaultService; }/*ww w .j a v a 2 s.c o m*/ final PrintService printService; final PrintService[] services = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); if (services.length == 0) { throw new PrintException("Unable to find a matching print service implementation."); } printService = services[0]; return printService; }