Estou tentando imprimir com o jasper e a resposta que tenho é:
Exception in thread "main" net.sf.jasperreports.engine.JRException: No suitable print service found.
at net.sf.jasperreports.engine.export.JRPrintServiceExporter.exportReport(JRPrintServiceExporter.java:149)
at PrintApp.testPrinting(PrintApp.java:67)
at PrintApp.main(PrintApp.java:28)
Acredito que esteja faltando driver ou algo do genero, se for esse o caso, por onde procurar, como proceder, não tenho experiencia tentando imprimir, se alguem puder me ajudar...
estou usando o trecho abaixo para tentar imprimir
private void testPrinting() throws JRException {
PrintService impressora = PrintServiceLookup.lookupDefaultPrintService();
System.out.println("get report template");
InputStream templateAsStream = ClassLoader.getSystemResourceAsStream("printertest.jrxml");
System.out.println("compile report");
JasperReport jasperReport = JasperCompileManager.compileReport(templateAsStream);
// submit parameters
Map parameters = new HashMap();
parameters.put("param1", "jasper report ...");
parameters.put("param2", "...rules");
System.out.println("fill the compiled template");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
//printServiceAttributeSet.add(MediaSizeName.ISO_A4);
printServiceAttributeSet.add(new PrinterName("Zebra105SL-1", null));
printRequestAttributeSet.add(new Copies(1));
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE);
System.out.println("export to printer");
exporter.exportReport();
// JasperPrintManager.printReport(jasperPrint, false);
}
--
Tomaz Lavieri
Sun Certified Java Programmer (SCJP 6)
meu blog =>
http://blog.tomazlavieri.com.br/
twitter =>
http://twitter.com/tomazlavieri
--
=================================================================
Site do grupo:
http://pbjug.org/
Para sair da lista, envie um e-mail para
pbjug-un...@groups.google.com
=================================================================