Disable page references in TOC

Hello to everyone.

I have a case where I need to add table of contents to an exising document.I am using the following link to achieve this goal: Manipulate PDF Document in C#|Aspose.PDF for .NET
(in part Add TOC to Existing PDF).

The version of used Apose.Pdf dll is 11.3

I wonder if you could help me to understand if I am able to hide page numbers in table of contents tree.

For instance, I have the following structure:

  1. My superHeading…1
    1.1. Subheading_1…2
    1.2. Subheading_2…3

Can I somehow hide these tabs and page numbers to get the following:

  1. My superHeading
    1.1. Subheading_1
    1.2. Subheading_2

I would be grateful if you could help me with this case.

Thanks in advance.

@cardagant,
There is no way to hide the page numbering in the TOC. We have logged a feature request under the ticket ID PDFNET-43056 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates. We are sorry for the inconvenience caused.

Best Regards,
Imran Rafique

Hi Imran,

I got your point. Thanks for the reply.

@cardagant

Thanks for your patience.

We are pleased to inform you that earlier logged feature request as PDFNET-43056, has been fulfilled in latest version Aspose.Pdf for .NET 17.11. Please try using following code snippet with latest release version and in case you face any issue, please feel free to contact us.

string outFile = GetOutputPath("43056.pdf");
Document doc = new Document();
Page tocPage = doc.Pages.Add();
TocInfo tocInfo = new TocInfo();
TextFragment title = new TextFragment("Table Of Contents");
title.TextState.FontSize = 20;
title.TextState.FontStyle = FontStyles.Bold;
tocInfo.Title = title;
//Add the list section to the sections collection of the Pdf document
tocPage.TocInfo = tocInfo;
//Define the format of the four levels list by setting the left margins and
//text format settings of each level

tocInfo.IsShowPageNumbers = false;
tocInfo.FormatArrayLength = 4;
tocInfo.FormatArray[0].Margin.Right = 0;
tocInfo.FormatArray[0].TextState.FontStyle = FontStyles.Bold | FontStyles.Italic;
tocInfo.FormatArray[1].Margin.Left = 30;
tocInfo.FormatArray[1].TextState.Underline = true;
tocInfo.FormatArray[1].TextState.FontSize = 10;
tocInfo.FormatArray[2].TextState.FontStyle = FontStyles.Bold;
tocInfo.FormatArray[3].TextState.FontStyle = FontStyles.Bold;
Page page = doc.Pages.Add();
//Add four headings in the section
for (int Level = 1; Level != 5; Level++)

{ Heading heading2 = new Heading(Level); TextSegment segment2 = new TextSegment(); heading2.TocPage = tocPage; heading2.Segments.Add(segment2); heading2.IsAutoSequence = true; segment2.Text = "this is heading of level " + Level; heading2.IsInList = true; page.Paragraphs.Add(heading2); }
doc.Save(outFile);

For your reference, a resultant file has been attached as well.

43056_review.pdf (4.1 KB)