DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=43808>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=43808 Summary: Apache FOP in a Servlet fails to work after upgrade to 0.94 Product: Fop Version: 0.94 Platform: PC OS/Version: Windows XP Status: NEW Severity: major Priority: P2 Component: general AssignedTo: [email protected] ReportedBy: [EMAIL PROTECTED] After upgrading FOP from 0.20 to 0.94, I can no longer create valid pdf files on the fly. I can create the pdf files in the conventional way OK, after updating the java code as recommended in the upgrade guide and swapping in the new jars into my application. The problem is we also create pdfs on the fly in a servlet. The code works differently here also (see: http://xmlgraphics.apache.org/fop/0.94/servlets.html). However, having implemented the changes recommended there exactly, the resulting pdf generated is damaged, and will not open. I get the message "Adobe Reader could not open 'letter.pdf' because it is either not a supported file type or because the file has been damaged." No other errors or exceptions signalling why the pdf is corrupted. The pdf generation works fine every other way, but not through the servlet. My code is as follows: public void convert2PDF(File xml, File xsl, HttpServletResponse response) throws IOException, FOPException, TransformerException { FopFactory fopFactory = FopFactory.newInstance(); TransformerFactory tFactory = TransformerFactory.newInstance(); fopFactory.setStrictValidation(false); //Setup a buffer to obtain the content length ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ //Setup FOP Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); //Setup Transformer Source xsltSrc = new StreamSource(xsl); Transformer transformer = tFactory.newTransformer(xsltSrc); //Make sure the XSL transformation's result is piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); //Setup input Source src = new StreamSource(xml); //Start the transformation and rendering process transformer.transform(src, res); //Prepare response response.setContentType("application/pdf"); response.setContentLength(out.size()); response.setHeader("Content-Disposition", "attachment; filename=Letter.pdf"); //Send content to Browser response.getOutputStream().write(out.toByteArray()); response.getOutputStream().flush(); etc.... -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee.
