Sorry I meant to send my previous post to the list, so all can see.

Looks like content and res are parameters to this method because I cant see their definition anywhere in the code you sent me.

Your code wont work because you need to set contentLength on the response after you have run the transformation and generated the PDF. You dont know the number of bytes in the PDF until after the line I have highlighted below:

From: [EMAIL PROTECTED]


try { XMLOutputter serializer = new XMLOutputter(); output = serializer.outputString(document); op = res.getOutputStream(); res.setContentType ("application/application/x-ms-download"); res.setHeader ("Content-Disposition", "attachment;filename=\"" + fileName + "\""); try{ //Setup driver Driver driver = new Driver(); //Setup logger Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); driver.setLogger(logger); MessageHandler.setScreenLogger(logger); //Setup Renderer (output format) driver.setRenderer(Driver.RENDER_PDF); File userConfigFile = new File("userconfig.xml"); Options options = new Options(userConfigFile);

        byte [] arrXML = content.getBytes();
        InputStream xml = new ByteArrayInputStream(arrXML);

        res.setContentLength(arrXML.length);

File xslt = new File("sl-pdf.xsl");
try {
driver.setOutputStream(op);
//Setup XSLT
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource(xslt));
//Setup input for XSLT transformation
Source src = new StreamSource(xml);
//Resulting SAX events (the generated FO) must be piped through o FOP


                Result result = new SAXResult(driver.getContentHandler());
                //Start XSLT transformation and FOP processing
                t.transform(src, result);
                op.flush();

*** bytes of PDF arent available until here.

                }

catch()
....

--
Besplatni e-mail - http://webmail.iskon.hr/

_________________________________________________________________ On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to