This is the code snip for page number in "n of m page" format.
Dim document As iTextSharp.text.Document = New iTextSharp.text.Document
Dim objrtf As iTextSharp.text.rtf.RtfWriter2 = iTextSharp.text.rtf.RtfWriter2.GetInstance(document, m)
Dim nFont As iTextSharp.text.Font = New iTextSharp.text.Font(Font.TIMES_ROMAN, 12, Font.NORMAL)
document.Open()
document.SetPageSize(iTextSharp.text.PageSize.LETTER)
Dim text As String = "This is Header "
Dim headers As New rtf.headerfooter.RtfHeaderFooterGroup
Dim header As rtf.headerfooter.RtfHeaderFooter
Dim headertable As iTextSharp.text.Table = New iTextSharp.text.Table(3)
headertable.WidthPercentage = 100
headertable.DefaultCellBorder = iTextSharp.text.Cell.NO_BORDER
Dim headercell As iTextSharp.text.Cell = New iTextSharp.text.Cell(New iTextSharp.text.Phrase(text, nFont))
headercell.HorizontalAlignment = iTextSharp.text.Cell.ALIGN_LEFT
headercell.Colspan = 2
headertable.AddCell(headercell)
Dim par As New Paragraph("Continued: Page ")
par.Add(New rtf.field.RtfPageNumber)
par.Add(" Of ")
par.Add(New rtf.field.RtfTotalPageNumber)
headercell = New iTextSharp.text.Cell(par)
headercell.Colspan = 1
headercell.HorizontalAlignment = iTextSharp.text.Cell.ALIGN_RIGHT
headertable.AddCell(headercell)
headertable.AddCell("")
headertable.AddCell("")
headertable.AddCell("")
header = New rtf.headerfooter.RtfHeaderFooter(headertable)
header.Alignment = rtf.RtfHeaderFooter.ALIGN_LEFT
headers.Border = iTextSharp.text.rtf.RtfHeaderFooter.NO_BORDER
headers.SetHeaderFooter(New rtf.headerfooter.RtfHeaderFooter(New Phrase("")), rtf.headerfooter.RtfHeaderFooter.DISPLAY_FIRST_PAGE)
headers.SetHeaderFooter(header, rtf.headerfooter.RtfHeaderFooter.DISPLAY_LEFT_PAGES)
headers.SetHeaderFooter(header, rtf.headerfooter.RtfHeaderFooter.DISPLAY_RIGHT_PAGES)
document.Header = headers