Your error is based on a misunderstanding of the basic concepts of iTextSharp.
A document is created in 5 steps:
PdfWriterthat will translate the content into a presentation, more specifically into a PDF document with one or more pages.
You are asking the document object for the current page number, yet the document isn't aware of its presentation. It doesn't even know that a PDF is produced.
You should ask the writer that is responsible for creating the PDF how many pages were already created;
writer.PageNumber will return that number.