Reputation: 81
Hi i have to create a pdf document from a grid view. Thus this is the problem that i encountered. When i tried to count the total number of pages, i cant seems to get the amount. Please help
THis are some of the coding i tried but to no avail.
Dim pdfDoc As New Document(PageSize.A2, 50, 50, 50, 50)
...................
...................
pdfDoc.PageCount
pdfDoc.PageSize
i tried to append the total page to my integer however for the first one what ive got is that page count is a writeOnly value while pagesize if i am not wrong is the size of the document.
Please help me thank you
Upvotes: 0
Views: 2078
Reputation: 77528
Your error is based on a misunderstanding of the basic concepts of iTextSharp.
A document is created in 5 steps:
PdfWriter
that 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.
Upvotes: 4