I don't know about the other lurkers, but I do the following:
First pass:
* Reserve space for the table of contents on a blank page
* Create an ArrayList of objects containing text and page numbers
* Add objects to the ArrayList as I encounter "interesting" content that should
be added to the TOC
* Finalize the document
Second pass:
* Use PdfStamper to add the TOC content to the existing PDF, in the blank space
I reserved in the first pass.
Greg
On Mar 8, 2011, at 8:09 AM, M. Niedermair wrote:
> Hi,
>
> the example 5.12 in the book show me, how I create a TOC.
> The TOC is created on the end of the pdf document and reorderd with
> writer.reorderPages(order). The TOC is now on the first page.
> If I use page numbers in the TOC with e.g.
> titles.add(new Paragraph(title.getContent() + " (" +
> writer.getPageNumber() + ")"));
> I get after reordering the wrong page numbers.
> My first idea was, to save the ArrayList with the Paragraphs with a
> ObjectOutputStream and load the data in a second run, but some classes
> have not implements the Interface Serializable.
> Now I use a quick and dirty solution with store only the content of the
> Paragraph as a String.
>
> Is there a better solution to get the right page numbers?
>
> By
> Michael
>
> ------------------------------------------------------------------------------
> What You Don't Know About Data Connectivity CAN Hurt You
> This paper provides an overview of data connectivity, details
> its effect on application quality, and explores various alternative
> solutions. http://p.sf.net/sfu/progress-d2d
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php