带有spring MVC的JasperReport:在客户端打印报告而不显示它 [英] JasperReport with spring MVC : print report on client side without displaying it

查看:667
本文介绍了带有spring MVC的JasperReport:在客户端打印报告而不显示它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Spring MVC - Angularjs应用程序。

我需要打印报告,我选择了JasperReport来做到这一点。

I am developping a Spring MVC - Angularjs application.
I need to print reports, I chose JasperReport to do that.

在我继续之前,我想知道我是否可以生成报告,然后将其直接打印在客户端计算机上设置的默认打印机上(打印机可以更改)根据用户的说法)在屏幕上不显示

我一直在寻找有关此特定需求的答案,但找不到任何答案。

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);


推荐答案

您可以在HTML页面中创建一个包含PDF的对象&安培;然后使用 print()方法打印它或使用 java.awt.print.PrinterJob 。见下面的例子。

You can create an object in HTML page which hold PDF & then print it using print() method or use java.awt.print.PrinterJob. See below examples.

  • Print embedded PDF from browser with Javascript, HTML5, AngularJS
  • Print a PDF from the browser
  • Print PDF directly from JavaScript
  • Print JasperPrint directly to printer ? - Java PrinterJob
  • Different examples using java.awt.print.PrinterJob

希望这会有所帮助你

这篇关于带有spring MVC的JasperReport:在客户端打印报告而不显示它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆