Hi Bruno,
 Right now I build the ToC in a separate PdfPTable and then at the end of
running everything else I reorder the pages. I based this off of the
watermark example actually. On every page I have Page x of y. Everything
works fine when the ToC is only one page as then I know in advance to
increment all the other page numbers when the onEndPage is called. I always
have the correct y value as it is calculated onEndDocument. The problem is
that when the ToC is more than one page (quite often) I don't know how many
pages to increment the rest of the document until the ToC is created at the
end of the document. So at the end I know that the ToC is three pages, but I
don't have a way to go back to the tpl that is used to increment all the
other pages by 3. I hope this makes sense. Is there any way to write all the
pages numbers in during onEndDocument? 

Thanks again,
 Dominic

-----Original Message-----
From: bruno [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 15, 2005 12:01 AM
To: Dominic Maricic
Cc: [email protected]
Subject: Re: [iText-questions] Page Numbering

Dominic Maricic wrote:

> Could someone please explain the concept of creating the pdf in 2 
> passes, the second time to create the page numbers. I can't do page 
> numbers using page events as it screws up when my table of contents is 
> greater than one page. It seems the best method would be 2 passes. I 
> would appreciate hearing how some of you have implemented this, or 
> suggestions on doing it.
>
There's an example on how to add Watermarks/pagenumbers/extra page to
an existing file (on your filesystem), here:
http://itextdocs.lowagie.com/tutorial/general/copystamp/index.html#pdfstampe
r
You'll have to adapt it to accept a file that is built in memory.

Are you making your ToC using page reordering?
Maybe you could generate your actual document in one ByteArrayOutputStream,
your ToC in another one, then use PdfCopy to concat both and PdfStamper to
number the pages. (It's just a suggestion, there's more than one way to 
do it.)
br,
Bruno



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to