I had the same problem, you should try my code :

try {

    XSLTInputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);

    XMLReader parser =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");

    Driver driver = new Driver();
    driver.setLogger(log);
    driver.setRenderer(Driver.RENDER_PDF);
    driver.setOutputStream(new FileOutputStream(pdfFile));
    ContentHandler contentHandler = driver.getContentHandler();
    parser.setContentHandler(contentHandler);
    driver.render(inputHandler.getParser(), inputHandler.getInputSource());

   } catch(Exception e){
    System.out.println("FOP Exception " + e.getMessage());

   }

As a matter of fact, you must pick up de contentHandler from fop and put it
in the parser....

Hope it'll help you...
Guillaume Patin

----- Original Message -----
From: Oliver Charlet <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 11, 2002 9:01 PM
Subject: Embedding problem


> Hi,
>
> I too have a problem embedding fop in my application.
> the following code (used inside a servlet) produces a zero byte pdf-file.
> xmlFile and xslFile hold an absolute Path to the input-files.
>
> ***************************************************
> ...
> org.apache.fop.apps.Driver driver = new Driver();
>
driver.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(PDFProxy.class
> .getName()));
> driver.setErrorDump(true);
> driver.setRenderer(Driver.RENDER_PDF);
> InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
> XMLReader parser = inputHandler.getParser();
> FileOutputStream fout = new FileOutputStream(new File("test.pdf"));
> driver.setOutputStream(fout);
> driver.render(parser, inputHandler.getInputSource());
> ...
> ***************************************************
>
> The Log says:
>
> DEBUG   10185   [fop     ] (): using SAX parser
> org.apache.xerces.parsers.SAXParser
>
> which is, as I understand, not an error. It seems to me, that the
generation
> is not started at all. when I try exactly the same from the commandline,
it
> just works fine.
> I have no clue what's happening inside the Driver here. Any help is
strongly
> appreciated!
>
> Thanks for listening
> olli
>

Reply via email to