This code will read the XML from a String object and write the PDF output back to the browser.:
 
      try
      {
         String fopstring = .... your function to generate the XML
         InputSource foSource = InputSource(new StringReader(fopstring));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         response.setContentType("application/pdf");
         Driver driver = new Driver(foSource, out);
         driver.setRenderer(Driver.RENDER_PDF);
         driver.run();
         byte[] content = out.toByteArray();
         response.setContentLength(content.length);
         response.getOutputStream().write(content);
         response.getOutputStream().flush();
         response.flushBuffer();
      }
 
Jim Urban

-----Original Message-----
From: Marc Jenzer [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 11, 2001 7:14 AM
To: [EMAIL PROTECTED]
Subject: how starting FOP without XML-File

Hallo
 
I generate my PDF-File in a servlet:
 
        File xmlFile    = new File("c:/temp/test.xml");
        File xslFile    = new File("c:/temp/test.xsl");
        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();
In the above example the xml input source is  a file. But I would rather pass the input source xml file (text.xml) in the memory. It's possible and how can I do this?
 
Thanks
 
Marc
 

Reply via email to