i want to stream a pdf report to a page, but some how i got funny character when
streaming. below is the code i wrote. i got this works at normal java application, but not
in portlet.
FacesContext ctx=FacesContext.getCurrentInstance();
String fullPath = getReportPath(reportName);
HttpServletResponse response=(HttpServletResponse)ctx.getExternalContext().getResponse();
response.setContentType("application/pdf");
response.addHeader("Content-Disposition", "attachment;
filename="+reportName+".pdf");
JasperPrint jasperPrint=JasperFillManager.fillReport(fullPath, parameters, new
JRBeanCollectionDataSource(list));
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
ctx.getApplication().getStateManager().saveSerializedView(ctx);
ctx.responseComplete();
the result i got is
%PDF-1.4 %âãÃÂà4 0 obj <>stream xÃÂÃÂ¥ÃÂÃÂnÃÂ0ÃÂïz ÃÂCenZÃÂ[ÃÂ.hÃÂöÃÂøçâÃÂÃÂ]qÃÂúúÃÂ¥ÃÂÃÂÃÂÃÂ$$ñÃÂd>ÃÂð*óÃÂÃÂ}MîWÃÂ`ÃÂ|4ïÃÂ¥ÃÂluHÃÂæûmrónõ'ùèÃÂpö9øÃÂ2ÃÂiÃÂÃÂÃÂ
ÃÂÃÂüýõiÃÂÃÂÃÂýTû
{ìÃÂçÃÂoöP?OÃÂææÃÂÃÂ"7þùÃÂ\ëðç<-ÃÂýzø
ÃÂ&ÃÂ`ÿ,ç+ÃÂ%ÃÂÃÂý;ÃÂÃÂ=(UñâÃÂJý~LÃÂ.ÃÂçÃÂKÃÂ1æÃÂ
ÃÂ"kÃÂæ2cÃÂ$ÃÂÃÂõ_>%ÃÂ4ê_âù TvÃÂÃÂ
Q
ä5Sòìý7ÃÂtTòì@$ÿðþÃÂc57[ðÃÂ|I=ÃÂú%A>_tÃÂ
ÃÂ`Q1næîÃÂ(à_DÃÂ
æùV~õ?ÃÂVþÃÂÃÂ>/HÃÂÿâú5EE
~ÃÂÃÂ¥@]1nîúy9è~ÃÂõÃÂëûRÃÂnÃÂÃÂÃÂ/äÃÂÃÂgÃÂ!ýÃÂ|ëÃÂq3
eÃÂ6`ÃÂG
eÃÂ4ànsÃÂÿÃÂÃÂÿÃÂøÃÂ-%IÿÃÂókÃÂÃÂþþ6:*@]1nîä53öÃÂ_ÃÂ7fmÃÂmèÃÂÃÂÃÂÃÂÃÂèÿ@ÃÂF|!õÃÂi7àìÃÂ"äÃÂ
However, if i use
JasperExportManager.exportReportToPdfFile(jasperPrint,"c:\\test.pdf");
i got the pdf nicely, but it save into my local, which does not serve my need.
So what is the correct way to stream a pdf? i want to do it like a popup message to let me
download the pdf.
Thanks in advance.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134107#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...