Hi. I am trying to get an XML file to get turned into a PDF file. Now,
if I just send it to the ServletOutputStream like this:
Document document = new Document();
response.setContentType("application/pdf");
PdfWriter.getInstance(document, responce.getOutputStream());
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
String path = getFileUrlPath("/WEB-INF/hello.xml", getServletContext());
parser.parse(path, new SAXiTextHandler(document));
then it works fine. The problem is that I need to have this work in IE
as well and I can't figure out how to implement the IE workaround where
you specify the byte length. This is what I've tried but it does not
work:
ByteArrayOutputStream baos = null;
Document document = new Document(PageSize.A4.rotate());
response.setContentType("application/pdf");
PdfWriter.getInstance(document, baos);
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
String path = getFileUrlPath("/WEB-INF/hello.xml", getServletContext());
parser.parse(path, new SAXiTextHandler(document));
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();
This is the error I get:
java.lang.NullPointerException
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:72)
at
java.io.BufferedOutputStream.write(BufferedOutputStream.java:116)
at
java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:126)
at com.lowagie.text.pdf.PdfIndirectObject.writeTo(Unknown
Source)
at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
at com.lowagie.text.Document.close(Unknown Source)
at com.lowagie.text.xml.SAXiTextHandler.handleEndingTags(Unknown
Source)
at com.lowagie.text.xml.SAXiTextHandler.endElement(Unknown
Source)
Can anyone help me?
Thanks
Isaac Goldstein
Federal Reserve Bank of NY
[EMAIL PROTECTED]
-------------------------------------------------------
This SF.NET email is sponsored by: FREE SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions