You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Solange Desseignes <sd...@calendra.com> on 2002/01/14 15:37:40 UTC
InputStream and OutputStream use in FOP servlet
Hi,
I use FOP to generate a PDF file from an XML file With a XSL/FO transformation.
The generation is made in a servlet.
Actually, I use the method described in the FOP Web site:
Driver driver = new Driver();
driver.setRenderer(Driver.RENDER_PDF);
InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
XMLReader parser = inputHandler.getParser();
driver.setOutputStream(new FileOutputStream(outFile));
driver.render(parser, inputHandler.getInputSource());
But, I want to use InputStream instead of File for xslFile and xmlFile (to use in war in Tomcat).
And, I don't know how do this !
Moreover, I have fonts configuration.
For the same reason, I can't use:
userConfigFile = new File(userConfig);
options = new Options(userConfigFile);
Can anybody help me ???
Thanks.
Solange Desseignes
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org
Re: InputStream and OutputStream use in FOP servlet
Posted by Philippe Van Der Gucht <ph...@uniway.be>.
Solange Desseignes wrote:
> I use FOP to generate a PDF file from an XML file With a XSL/FO transformation.
> The generation is made in a servlet.
>
> Actually, I use the method described in the FOP Web site:
> Driver driver = new Driver();
> driver.setRenderer(Driver.RENDER_PDF);
> InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
> XMLReader parser = inputHandler.getParser();
> driver.setOutputStream(new FileOutputStream(outFile));
> driver.render(parser, inputHandler.getInputSource());
>
> But, I want to use InputStream instead of File for xslFile and xmlFile (to use in war in Tomcat).
> And, I don't know how do this !
Implement your own xsl transformator class and put something like this in it:
public void transform(Document document, OutputStream out) {
try {
Source source = new DOMSource(document);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new
StreamSource(new File(mStylesheet)));
transformer.transform(source, new StreamResult(out));
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
Philippe.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org