Hi,
 
here is a code snippet from or servlet:
 
      java.io.File xmlFile = new java.io.File(xmlFileName);
      java.io.File xslFile = new java.io.File(xslFileName);
      
      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();
Hope this helps.
 
Regards,

_______________________________________
Erik Rehrmann - IOn AG
[EMAIL PROTECTED]


-----Ursprüngliche Nachricht-----
Von: VIRUEGA Pierre [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 16. Juli 2001 12:58
An: [EMAIL PROTECTED]
Betreff: FOP in a servlet

Hello,
I need some help about how to embed FOP in a servlet.
I know there is an example on the FOP site but it is only with one parameter, the same as:
Fop foo.fo foo.pdf

and what I want to do is similar to:
Fop -xml foo.xml -xsl foo.fo foo.pdf

I found the following code on the FOP FAQ as an example =

   response.setContentType("application/pdf");
   Driver d = new Driver();
   // this doesn't compile
   //Driver.setRenderer(RENDER_PDF);
 
   InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
   XMLReader parser = inputHandler.getParser(); // error at getParser
   d.buildFOTree(parser, inputHandler.getInputSource());
   d.format();
   d.setOutputStream(response.getOutputStream());
   d.render();

But it failed  with the message =
java.lang.NullPointerException
        at org.apache.fop.apps.InputHandler.createParser(InputHandler.java:58)
        at org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:117)
        at NewFopServlet.buildPDFDoc(NewFopServlet.java:157)
        at NewFopServlet.doGet(NewFopServlet.java:96)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

Does anyone has solved the same problem?
Thks
Pierre

**************************************************************************************************
This e-mail contains confidential information or information belonging
to Sofrecom and is intended solely for the addressees.
The unauthorised disclosure, use, dissemination or copying (either whole
or partial) of this e-mail, or any information it contains, is prohibited.
E-mails are susceptible to alteration and their integrity cannot be guaranteed.
Sofrecom shall not be liable for this e-mail if modified or falsified.
If you are not the intended recipient of this e-mail, please delete it
 immediately from your system and notify the sender of the wrong delivery
and the mail deletion.

** eSafe scanned this email for viruses, vandals and malicious content **
**************************************************************************************************

Reply via email to