Hello,
I am using JFreeChart and iText.
I am creating a chart and saving it as pdf in my file system.
When I open it, it works (pdf with content is displayed).
When I tried to serve the pdf to browser as attachment, I get error as Adobe
cannot open the file as it is damaged or corrupted.
If I try feeding the pdf inline, the header of the webpage changes and
everything else remains the same. Status bar shows Done.
For a long time nothing happens. (pdf file size on file system is 120 kb)
My code for serving pdf to browser is:
*String pdfFileName = System.getProperty("user.home")
+ "/pragmatic" + remoteAddr + ".pdf";
File file = new File(pdfFileName);
BufferedInputStream in = new BufferedInputStream(new
FileInputStream(file));
byte[] b = new byte[(int) file.length()];
in.read(b);
response.setContentType("application/pdf");
response.setContentLength(b.length);
response.addHeader("Content-Disposition", "attachment;
filename=" + pdfFileName);
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
response.setContentLength((int) file.length());
int readBytes = 0;
while ((readBytes = in.read()) != -1) {
response.getOutputStream().write(readBytes);
}
response.getOutputStream().flush();*
Can you help me out in figuring what the problem might be and what can I do
to overcome that!
Thanks.
Appreciate your help.
Regards,
Venkata Rakesh Pachawa
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/