How to print in jasper directly

2019-08-06 20:01发布

问题:

I have to hook up a thermal printer to my java app. I want to know how to print without print manager. I have come so far

JasperDesign jspDesign = JRXmlLoader.load(reportSource);
JasperReport jspReport = JasperCompileManager.compileReport(jspDesign);
JasperPrint jspPrint = JasperFillManager.fillReport(jspReport, params, datasource);
JRExporter exporter = new JRPrintServiceExporter();

JasperPrintManager.printReport(jspPrint, true);

I want to cut the "JasperPrintManager" and print after click the button. Anybody knows how to do this?

回答1:

Not really sure if i understand youre Problem correctly, but if you write

JasperPrintManager.printReport(jspPrint, false);

Jasper will send your report directly to the printer which is set as standard in the system. Hope this helps you.