Hi Gustavo,

the following works great:

      ByteArrayOutputStream out = new ByteArrayOutputStream();            
      Driver driver = new Driver();
      driver.setRenderer(Driver.RENDER_PDF);
      InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
      org.xml.sax.XMLReader parser = inputHandler.getParser();
      driver.buildFOTree(parser, inputHandler.getInputSource());
      driver.format();
      driver.setOutputStream(out);
      driver.render();

      response.setContentType("application/pdf");
      byte[] content = out.toByteArray();
      response.setContentLength(content.length);
      response.getOutputStream().write(content);
      response.getOutputStream().flush();

This example lets the servlet stream the result directly to the client browser. If you 
want to have the pdf file on your disk instead, just write use an other output stream!

It currently does not work for IE5.5, but I'll check the hint of Alex McLintock 
earlier in this list.

Hope this helps you out,
_______________________________________
Erik Rehrmann - IOn AG
[EMAIL PROTECTED]




> -----Ursprüngliche Nachricht-----
> Von: Wolf Gustavo (SGC-EXT) [mailto:[EMAIL PROTECTED]]
> Gesendet: Freitag, 6. Juli 2001 17:11
> An: '[EMAIL PROTECTED]'
> Betreff: RE: Need Working Sample
> 
> 
> Hi Jim,
>             I have exactly the same problem, and I've just found a non
> elegant, working solution:
> 
> I generate my XML file, and then call the command line Fop 
> from within my
> servlet:
> 
> Runtime.getRuntime().exec(new String[]{"java.exe", "-cp",
> "c:\\fop\\Fop-0.18.1-DEV\\fop.jar;c:\\fop\\Fop-0.18.1-DEV\\lib
> \\w3c.jar;c:\\
> fop\\Fop-0.18.1-DEV\\lib\\xalan-2.0.0.jar;c:\\fop\\Fop-0.18.1-
> DEV\\lib\\xerc
> es-1.2.3.jar;c:\\fop\\Fop-0.18.1-DEV\\lib\\jimi-1.0.jar",
> "org.apache.fop.apps.Fop", "-xml" , "c:\\prueba.xml", "-xsl" ,
> "c:\\prueba.xsl", "-pdf" , "c:\\prueba.pdf"}); 
> 
> As I said, it is NOT elegant, but after sweating for days 
> with problems of
> all type doing the elegant thing, I get my beautiful PDF on disk.
> 
> Of course you should adapt the names of trhe directories  and 
> the xml and
> xsl files.
> 
> Cheers,
>                        Gustavo
> 
> PS: if someone has an elegant solution I would be happy to 
> use it too. 
> 
> >  -----Message d'origine-----
> > De :        Jim Urban [mailto:[EMAIL PROTECTED]] 
> > Envoyé :    vendredi, 6. juillet 2001 17:09
> > Ŕ : [EMAIL PROTECTED]
> > Objet :     Need Working Sample
> > 
> > Hi, I am new to FOP.  I have a servlet which dynamically 
> generates XML.  I
> > need to apply an XSL stylesheet containing FO tags to generate a FO
> > version of the XML and then I need to run this FO version of the XML
> > through FOP (or Driver) so the servlet can return a 
> dynamically created
> > PDF to the browser.  Does anyone have a working example of 
> how to do this?
> > Only the XSL style sheet containing the FO tags used in the initial
> > transform will be on disk.  Please help, I have to get this working.
> > 
> > Thanks,
> > 
> > Jim Urban
> > Product Manager
> > Netsteps Inc.
> > Suite 505E
> > 1 Pierce Pl.
> > Itasca, IL  60143
> > Voice:  (630) 250-3045 x2164
> > Fax:  (630) 250-3046
> > 
> > << Fichier: ATT14204.txt>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
> 
> 

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

Reply via email to