Free Support Forum -

Page number in a table of contents


I would like to create à pdf document with a Table of Contents(i work with the APi .net), i have make intern hyperlinks on the page, but i would like near ,the hyperlink, write the page number of the destination of the hyperlink, How can i do.

Thanks for your help

Sorry for my English, i’m french.


I don't think I fully understand your question. But if you are looking to create a table of contents with page number then the following code will do that:

Pdf pdf = new Pdf();

//Create the Table Of Contents. Add it to the pdf like a common Section.

ListSection tocSection = new ListSection("Table Of Contents");

tocSection.ListType = ListType.TableOfContents;


//Define the format of the four levels' list.

tocSection.ListFormatArray.Length = 4;

tocSection.ListFormatArray[0].LeftMargin = 0;

tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;

tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;

tocSection.ListFormatArray[1].LeftMargin = 10;

tocSection.ListFormatArray[1].TextInfo.IsUnderline = true;

tocSection.ListFormatArray[1].TextInfo.FontSize = 10;

tocSection.ListFormatArray[2].LeftMargin = 20;

tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;

tocSection.ListFormatArray[3].LeftMargin = 30;

tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;

//Add four headings.

Aspose.Pdf.Section sec1 = pdf.Sections.Add();

for (int Level = 1; Level != 5; Level++)


Heading heading2 = new Heading(pdf, sec1, Level);

Segment segment2 = new Segment(heading2);


heading2.IsAutoSequence = true;

segment2.Content = "this is heading of level ";

segment2.Content += Level.ToString();

//Add the heading into Table Of Contents.

heading2.IsInList = true;





thanks, it 's exactly that i want.