We have Flex on the front end and Java on the back end. When a user will request for a PDF file, request will go to the Java backend, where a PDF file will be generated using Jasper Reports. What we dont know is how to display this PDF file in browser; since we dont want to use JSP/Servlets etc - It has to be flex only. Any suggestions?
3 回答
Flash Player cannot natively render PDF files. This is possible using Adobe AIR but not in a Flex application. Your best bet is to call navigateToURL() and open a Servlet in a new browser tab/window. The Servlet can simply write contents of the PDF file to the OutputStream and set the appropriate HTTP headers.
我认为这个问题很老,但它可能对其他人有帮助,Jasper Forge 他们自己开发了一个新库,它直接处理 JasperReports,我的意思是它不是 PDF 查看器,而是 JasperReport 导出工具,你可以从这里下载
我通过使用JasperServer进行了尝试,在查看报告时,您可以选择不同的选项来导出它,其中之一是 flash,它工作得很好
对于初学者来说,PDF 并不总是显示在浏览器中。这取决于用户的设置。您基本上将它们放在 pdf 文件的标题上,然后他们下载它,或者在浏览器中打开像 Acrobat Reader 这样的程序来显示它。
不知道这是如何在 flex 中完成的,我想如果你使用 Java,一个简单的 servlet 就可以做到。