Hi,

I just upgraded our program to use FOP 0.20.0
We embedded FOP and used the old official method to call it.

I mean using somthing like this :
        Driver driver = new Driver();
        driver.setRenderer(Driver.RENDER_PDF);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        driver.setOutputStream(out);

        ContentHandler cnth = driver.getContentHandler();
        sendSAXEvents(cnth);

        driver.format();
        driver.render();

        byte[] content = out.toByteArray();

However this not longer works with 0.20.0
for a few reasons:
1°) there is no driver.format() method.
2°) there is no driver.render() method (there are two version with
parameters).

Still removing those two method calls still does not work as
using the ContentHandler returned by driver.getContentHandler
generates a NullPointException because the
_treeBuilder.setStreamRenderer(streamRenderer)
is not called (and the FOTreeBuilder needs it).

so I changed a few lines in Driver.java to fix this...
I added a method driver.prepareRender() that setups the _treeBuilder
I changed both render method to use the new prepareRender
so my program now looks like this (and works).

        Driver driver= new Driver();
        driver.setRenderer(Driver.RENDER_PDF);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        driver.setOutputStream(out);
        driver.prepareRender();

        ContentHandler cnth = driver.getContentHandler();
        sendSAXEvents(cnth);

        byte[] content = out.toByteArray();

What do you think ? Was it a good idea ? anyother idea on how to acheive
this ?

I though about putting back the render() method (without parameters), but I
tough it was
weird as it would need to be called before the SAX events are generated.

Michel Lehon
[EMAIL PROTECTED]
SAS Data Warehousing and Web Enablement.

Driver.java

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

Reply via email to