[EMAIL PROTECTED] schreef:
> Hi,
> 
> I am new to itext and using itext to generate a PDF document. The content in 
> the PDF are not static but dynamic in nature and I don't know before hand as 
> how long the PDF file is going to be generated.
> I need to add a 'Table of contents' page to this document. Any pointers or 
> code snippet to do this will be highly helpful.

There's more than one way to do this.

Either you keep track of the titles and page numbers you
want to display in the TOC. You can do this in a special
object or even better: by creating an outline tree.
Then add all this when you've finished adding all the
other content (if the TOC needs to be in front, you might
want to reorder the pages).

Or you create the TOC on the fly in a second PDF (maybe
in memory) and afterwards you concatenate this second PDF
with the PDF that has the actual content.

The first approach is nice because you can preserve
internal links, but typically you'll use numbers
i, ii, iii, iv,... for the TOC and 1, 2, 3, 4,...
for the actual content.

The second approach works best if you want the TOC
to be in front starting with page 1, 2, 3,... and
keep on using the same numbering for the actual content
(you'll add the page numbers in the second go).

--
This answer is provided by 1T3XT BVBA

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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