GWT:从服务器发送PDF文档到客户端
我有一个 RPC 服务,其中一种方法是使用 Pentaho Reporting Engine 生成报告。报告是 PDF 文件。我想做的是,当用户请求报告时,报告会发送回给他并弹出保存对话框或其他内容。我在我的服务方法中尝试了这个:
Resource res = manager.createDirectly(new URL(reportUrl), MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
report.getParameterValues().put("journalName", "FooBar");
this.getThreadLocalResponse().setContentType("application/pdf");
PdfReportUtil.createPDF(report, this.getThreadLocalResponse().getOutputStream());
但它不起作用。怎样才能做到呢?
I have an RPC service and one of the method is generating a report using Pentaho Reporting Engine. Report is an PDF file. What I'd like to do, is when user request a report, the report is sent back to him and save dialog or sth pops up. I tried this inside my service method:
Resource res = manager.createDirectly(new URL(reportUrl), MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
report.getParameterValues().put("journalName", "FooBar");
this.getThreadLocalResponse().setContentType("application/pdf");
PdfReportUtil.createPDF(report, this.getThreadLocalResponse().getOutputStream());
But it doesn't work. How it can be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的做法有点不同。我有一个单独的 servlet,用于生成 PDF。在客户端上,执行如下操作:
servlet,DownloadPDF 看起来像这样:
I do it a little bit differently. I've got a separate servlet that I use to generate the PDF. On the client, do something like:
The servlet, DownloadPDF looks something like this: