Recently someone suggested using SAX events to run XML through XSLT then FOP and to send the PDF back to the browser from a servlet. I tried implmenting this (see code below) but all I don't get any output back. I even routed the output to a file, and the file was empty. My old code worked great, but I was told I was wasting memory. Can someone tell me why this code does not work?
Thanks, Jim Urban Product Manager Netsteps Inc. Suite 505E 1 Pierce Pl. Itasca, IL 60143 Voice: (630) 250-3045 x2164 Fax: (630) 250-3046 public void renderFO(Transformer pdfTransformer, Source iInputSource, HttpServletResponse uResponse) { try { OutputStream out = uResponse.getOutputStream(); uResponse.setContentType("application/pdf"); Driver driver = new Driver(); driver.setRenderer(driver.RENDER_PDF); driver.setOutputStream(out); // ------- // Create SAXResult based on FOP Driver content handler // which will accept SAX events and build FOP tree // ------- Result saxResult = new SAXResult(driver.getContentHandler()); // Use the Transformer to transform an XML Source and // send the output to a Result object. Implicitely it will // create the FOP tree by firing SAX events. pdfTransformer.transform(iInputSource, saxResult); // The user is already viewing the PDF! out.flush(); out.close(); } catch (TransformerException e1) { System.err.println("Unable to generate PDF: " + e1.toString()); } catch (IOException e2) { System.err.println("File error: " + e2.toString()); } }
<<attachment: winmail.dat>>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]