Free Support Forum -

Excluding cover and table of content pages from page number counting

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?


An investigation ticket as PDFNET-49473 has been logged in our issue tracking system for the sake of your requirements. We will further analyze whether they can be achieved or not and let you know as soon as the logged ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.