tags:

views:

49

answers:

0

I'm creating a PDF using iTextSharp and after adding all my pages, I want to be able to add a table of contents at the beginning. Is there a way to "rewind" the PDFWriter?

var d = new Document(PageSize.LETTER);
PdfWriter w = PdfWriter.GetInstance(d, new FileStream("test.pdf", FileMode.Create));
d.Open();
for (var i = 0; i < 200; i++) {
    d.Add(new Paragraph("Hola Senor Page:" + w.CurrentPageNumber.ToString()));
}

w.GoToPage1;
d.Add("Table of Contents here");

d.Close();

is this possible?