KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i have a EJB site with glassfish 3.1 + JSF for jasperreport 4.0.1. the site has no problem on streaming pdf, but it products blank PDF while printing PDF with runReportToPdfStream, below is the code snippet: EJB public class BookEJB { public void printReport() throws ClassNotFoundException, IOException, JRException { Map parameterMap = new HashMap(); FacesContext ctx = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse(); InputStream reportStream = ctx.getExternalContext().getResourceAsStream("/reports/test.jasper"); ServletOutputStream servletOutputStream = response.getOutputStream(); servletOutputStream.flush(); response.setContentType("application/pdf"); JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream, parameterMap); servletOutputStream.flush(); servletOutputStream.close(); ctx.responseComplete(); }} test.jrxml - a simple report without SQL connection <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="test" pageWidth="800" pageHeight="1200" columnWidth="555" leftMargin="25" rightMargin="25" topMargin="30" bottomMargin="30"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <queryString> <![CDATA[]]> </queryString> <pageHeader> <band height="100"> <staticText> <reportElement x="0" y="0" width="285" height="36"/>
Tags (comma-separated)
Save Edits
Cancel