I’m trying to find out how I can exclude the table of content page from the page number count, basically very similar to what this previous post was trying to do. Here is a code snippet to demonstrate the problem:
var pdfDocument = new Document();
var tocInfo = new TocInfo();
var tocPage = pdfDocument.Pages.Add();
tocPage.TocInfo = tocInfo;
var firstPage = pdfDocument.Pages.Add();
firstPage.Paragraphs.Add(new TextFragment("Content of first page"));
tocPage.Paragraphs.Add(new Heading(1)
{
TocPage = tocPage,
DestinationPage = firstPage,
Top = firstPage.Rect.Height,
Segments = {new TextSegment {Text = "First page"}}
});
The PDF generated with the above code will have a table of content page that says the first page starts at page 2, because page 1 is the table of content page, as can be seen in the tocPage.Number
property. Since the Number
property is read only, is there a way to exclude any special page from page number counting so that the table of content can reflect a more practical page numbering?