简体   繁体   English

带有spring MVC的JasperReport:在客户端打印报告而不显示它

[英]JasperReport with spring MVC : print report on client side without displaying it

I am developping a Spring MVC - Angularjs application. 我正在开发一个Spring MVC - Angularjs应用程序。
I need to print reports, I chose JasperReport to do that. 我需要打印报告,我选择了JasperReport来做到这一点。

Before I move on, I want to know if I can generate a report, then directly print it on the default printer set up on the client computer (printer which can change according to users) without displaying it on screen. 在我继续之前,我想知道是否可以生成报告,然后直接将其打印在客户端计算机上设置的默认打印机(可根据用户更改的打印机) 而不在屏幕上显示。
I have been looking for answers on this specific need, but couldn't find any. 我一直在寻找这个特定需求的答案,但找不到任何答案。

If anyone knows about it.... 如果有人知道它....

Source to generate report and print it: 生成报告并打印它的来源:

HashMap<String, Object> params = new HashMap<String, Object>(); 
params.put("Title", "My Report");

InputStream reportStream = this.getClass().getResourceAsStream(TEMPLATE); 
JasperDesign jd = JRXmlLoader.load(reportStream);
JasperReport jr = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport(jr, params, datasource.getDataSource());

JasperPrintManager.printReport(jp, false);

You can create an object in HTML page which hold PDF & then print it using print() method or use java.awt.print.PrinterJob . 您可以在HTML页面中创建一个包含PDF的对象,然后使用print()方法打印它或使用java.awt.print.PrinterJob See below examples. 见下面的例子。

Hope this helps you 希望这对你有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM