Kris Raney wrote:
I still think it's a good idea to
make memory-friendly Section and Chapter helpers available

I've thought about this problem, and I decided not
to look at the extensions you've written. Instead
I introduced a new Interface:

LargeElement extends Element

Currently three classes are implementing the LargeElement
interface: Section (and Chapter), PdfPTable and Table.

I have done some simple tests with PDF files that look OK,
but this functionality should be tested more thoroughly.

In pseudocode this is what you can do:

LargeElement e = new LargeElementImp();
e.setCompleted(false);
e.add(a lot of content);
do while there's still content {
        document.add(e);
        e.add(a lot of content);
}
e.setCompleted(true);
document.add(e);

After a large object has been added to all the listeners
of the Document, the Document will check if the large object
was completed. If not, it will flush all the content that
was already added.
There are some caveats: with tables, you risk deleting
partially filled rows, so be careful!
With Chapter/Section: if you have a Section of a Chapter
that hasn't been completed yet, you have to mark it with
setCompleted(false); otherwise it will be removed from
the Chapter object, and an IllegalStateException will be
thrown if you try to add more content to that Section.

Now that I think of it: I might change the methods
setCompleted and isCompleted into setComplete and
isComplete.
br,
Bruno

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to