You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "capra.john.doe@voila.fr" <ca...@voila.fr> on 2002/02/15 12:57:03 UTC
FOP and servlets
Hi,
I've been using FOP for a few days and i have a problem with displaying PDF through a browser with FOP. I'm using FOP 0.20.1 with Xalan 1.2 and Xerces 1.2. Here's a sample of my servlet source :
String xmlString = request.getParameter("XML");
String xslString = resquest.getParameter("XSL");
ByteArrayOutputStream fo = new ByteArrayOutputStream();
//XSLT transformation
XSLTProcessor lProcessor = XSLTProcessorFactory.getProcessor();
lProcessor.process(new XSLTInputSource(new StringReader(xmlString)), new XSLTInputSource(new StringReader(xslString), new XLSTResultTarget(fo));
// PDF generation with FOP
Driver lFOPDriver = new Driver();
InputSource FOSource = new InputSource(fo);
response.setContentType("application/pdf");
ServletOutputStream output = response.getOutputStream();
lFOPDriver.setOutputStream(output);
lFOPDriver.setRenderer(RENDER_PDF);
XMLReader reader = (XMLReader) Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
lFOPDriver.setXmlReader(reader);
lFOPDriver.setInputSource(FOSource);
lFOPDriver.run();
output.flush();
output.close();
When I call this servlet, the browser don't display the generated PDF but I 've noticed that it appears in my Temporary Internet Files.
Does anyone have an idea ?
Regards.
JD.
____________________________________________________________
Faites un voeu et puis Voila ! www.voila.fr
Avec Voila Mail, consultez vos e-mails sur votre mobile Wap.
Re: FOP and servlets
Posted by James Richardson <ja...@db.com>.
Bart Locanthi wrote:
>
>
> application/x-pdf, not application/pdf
[50lines of quoted stuff deleted]
>
Unlikely. Look in the archives about IE's handling of content types.
Of course this has nothing to do with FOP.
Cheers
James
Re: FOP and servlets
Posted by Bart Locanthi <ba...@sabl.com>.
application/x-pdf, not application/pdf
capra.john.doe@voila.fr wrote:
> Hi,
>
> I've been using FOP for a few days and i have a problem with displaying PDF through a browser with FOP. I'm using FOP 0.20.1 with Xalan 1.2 and Xerces 1.2. Here's a sample of my servlet source :
>
> String xmlString = request.getParameter("XML");
> String xslString = resquest.getParameter("XSL");
> ByteArrayOutputStream fo = new ByteArrayOutputStream();
> //XSLT transformation
> XSLTProcessor lProcessor = XSLTProcessorFactory.getProcessor();
> lProcessor.process(new XSLTInputSource(new StringReader(xmlString)), new XSLTInputSource(new StringReader(xslString), new XLSTResultTarget(fo));
> // PDF generation with FOP
> Driver lFOPDriver = new Driver();
> InputSource FOSource = new InputSource(fo);
> response.setContentType("application/pdf");
> ServletOutputStream output = response.getOutputStream();
> lFOPDriver.setOutputStream(output);
> lFOPDriver.setRenderer(RENDER_PDF);
> XMLReader reader = (XMLReader) Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
> lFOPDriver.setXmlReader(reader);
> lFOPDriver.setInputSource(FOSource);
> lFOPDriver.run();
> output.flush();
> output.close();
>
> When I call this servlet, the browser don't display the generated PDF but I 've noticed that it appears in my Temporary Internet Files.
>
> Does anyone have an idea ?
>
> Regards.
>
> JD.
> ____________________________________________________________
> Faites un voeu et puis Voila ! www.voila.fr
> Avec Voila Mail, consultez vos e-mails sur votre mobile Wap.
>