I set up logger before I begin generating PDF's
//code for setting up logger
Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
PatternFormatter formatter = new PatternFormatter( "
[%{priority}]:%{message}\n%{throwable}" );
LogTarget target = new StreamTarget(System.out, formatter);
Logger log = hierarchy.getLoggerFor("fop");

I wound up writing a class that extends Driver, then I fire SAX events
instead of using XSLT.  This gave me a little more control and avoided
having to write an XML file when I get data from the database.  If I had it
to do all over again, I'd use a stylesheet and feed it a stream of XML data
from the database.  That how-to should be in the archives somewhere.  I
added some convenience methods to the class and set up my attribute objects
as static variables.  However the inline code would look something like the

Driver driver = new Driver();

FileOutputStream out = new FileOutputStream( "path/to/pdffile.pdf" );

driver.setLogger( log );
driver.setRenderer( billingFop.RENDER_PDF );
DefaultHandler handler = driver.getContentHandler();

handler.startElement( "http://www.w3.org/1999/XSL/Format";, "root",
"fo:root", new AttributesImpl() );
AttributesImpl blockAttrib = new AttributesImpl();
blockAttrib.addAttribute( FOURI, "font-size", "font-size", "CDATA", "9pt"
handler.startElement( "http://www.w3.org/1999/XSL/Format";, "block",
"fo:block", blockAttrib );
handler.characters( "text stuff in block".toCharArray(), 0, "text stuff in
block".length() );
handler.endElement( "http://www.w3.org/1999/XSL/Format";, "block",
handler.endElement( "http://www.w3.org/1999/XSL/Format";, "root",


Not sure if that helps you at all, but it's one way to do it.  It DOES NOT
REUSE PDF renderer, but it has no problems with leaking memory.  It takes a
little over 4 hours to run on a AS/400 with 8 G3 processors and lot's O
ram.  It's a pretty complex report with alternating colored lines, OMR
marks, OCR font markings and different layouts for the first page, second
page and then alternating odd/even pages.  It's a good alternative for a


                    APACHE.ORG                                                 To:     
"'[EMAIL PROTECTED]'"                        
<[EMAIL PROTECTED]>                                 
                    12/13/01 02:07 AM                                          cc:     
                    Please respond to fop-dev                                  
Subject:     RE: RE: reuse of PDFRenderer                 

Hi John,

thanks for reply. Could you give me a hint - what version of fop are you
using and the code pattern of the usage. I use very simple approach:

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Driver driver = new Driver();
            driver.setInputSource(foSrc); // defined previously
            // save
           FileOutputStream objF = new FileOutputStream(pstrFile);

This approach locks some memory even if I call gc() and exit the function.



-----Original Message-----
Sent: Wednesday, December 12, 2001 8:44 PM
Subject: Re: reuse of PDFRenderer

I don't have a solution, but I also would like to reuse or reset the
driver.  I remember seeing that reset had problems, any fixes or a way to
make it work?   I'm generating 70,000 pdf's with pretty complex fo markup
and would like to speed up the process anyway possible.  I have no memory
problems (avg pdf is less than 10 pages), I would just like to speed up the
rendering by reusing the driver.




                    12/12/01 09:31 AM
cc:     Dvorák Zdenek <[EMAIL PROTECTED]>
                    Please respond to fop-dev
Subject:     reuse of PDFRenderer


this is my first time contacting the mail group. If you received this mail
in error, I am sorry.

I am building a batch printing application. This application processes huge
number of documents.

I did some measurements and found out that every document beeing processed
(Driver.run()) locks about 6 kB of memory. I invastigated the problem and
did a pool of Driver objects to reuse them. This doesn't help since the
Driver object by starting the setRenderer() method instantiates a
PDFRenderer and this is the object that after beeing finished still keeps
allocated memory. If I reset()  the driver to perform another
it creates a corrupted PDF since the renderer was not reinitialized (my
Does anyone have an idea how to make a pool of Driver, PDFRenderer objects
or how to get rid of the memory leak?

thanks Zdenek

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

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

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