We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Multiple Table of Contents issues (Version 18.4.1)

I’m running into multiple frustrating issues when trying to merge a document and add in a ToC dynamically. Some of these issues seem to have been previously reported several years ago, which concerns me that they are still unresolved.

Issue 1: Bookmark to Table of Contents isn’t working when it spans more than 1 page. (Reported in 2015 PDFNEWNET-40033).

Issue 2: The ToC title shows up multiple times per page. This happens if I call document.ProcessParagraphs() manually, which I have to do in order to make the page numbering work correctly when a ToC is added (See issue #3).

Issue 3: ToC pages are not counted when stamping pages with a page number unless you call document.ProcessParagraphs() manually, which causes issue #2.

Perhaps I’m missing something, but I’ve struggled to find good examples. Most I find fragmented and lacking.

Additionally, the code documentation is often times confusing. Example: TocInfo.IsCountTocPages property says “Gets or sets is count or passed toc pages”. What??

I typically don’t complain, but I’m not going to beat around the bush here. I’m a bit surprised at the number of bugs plaguing this library, especially with the quantity I’ve run into regarding this single feature (Table of Contents). Looking at your bug fix log from previous releases, it is clear that you have a quality control issue. Please fix this, or I’ll be forced to move on to another product. Frankly, I’d advise any new users to carefully consider other options.

Example code:
var lic = new Aspose.Pdf.License();
lic.SetLicense(new FileStream(@“Aspose.Pdf.lic”, FileMode.Open));

using (var mergedDocument = new Document())
	var tocBookmark = new OutlineItemCollection(mergedDocument.Outlines);
	tocBookmark.Title = "Table of Contents";

	var tocInfo = new TocInfo();
	tocInfo.LineDash = TabLeaderType.None;
	var title = new TextFragment("Table Of Contents");
	title.TextState.FontSize = 12;
	title.TextState.FontStyle = FontStyles.Bold;
	tocInfo.Title = title;
	tocInfo.FormatArrayLength = 2;
	tocInfo.FormatArray[0].Margin.Left = 0;
	tocInfo.FormatArray[0].Margin.Right = 0;
	tocInfo.FormatArray[0].Margin.Top = 5;
	tocInfo.FormatArray[0].Margin.Bottom = 5;
	tocInfo.FormatArray[0].LineDash = TabLeaderType.None;
	tocInfo.FormatArray[1].Margin.Left = 10;
	tocInfo.FormatArray[1].Margin.Right = 0;
	tocInfo.FormatArray[1].Margin.Top = 5;
	tocInfo.FormatArray[1].Margin.Bottom = 5;
	tocInfo.FormatArray[1].LineDash = TabLeaderType.None;
	tocInfo.FormatArray[1].TextState.FontSize = 10;

	var tocPage = mergedDocument.Pages.Insert(1);
	tocPage.TocInfo = tocInfo;
	for (var i = 0; i < 200; i++)
		var newPage = mergedDocument.Pages.Add();

		var pageBookmark = new OutlineItemCollection(mergedDocument.Outlines);
		pageBookmark.Title = "Page " + (i + 1);
		pageBookmark.Action = new GoToAction(newPage);
		var heading = new Heading(1);
		var segment = new TextSegment();
		heading.DestinationPage = newPage;
		heading.IsAutoSequence = false;
		segment.Text = "Page " + (i + 1);
		heading.TextState.Font = FontRepository.FindFont("Arial Unicode MS");
		heading.IsInList = true;

	tocBookmark.Action = new GoToAction(tocPage);

	var pageNumberStamp = new PageNumberStamp()
		Background = false,
		Format = "Page # of " + mergedDocument.Pages.Count,
		BottomMargin = 10,
		HorizontalAlignment = HorizontalAlignment.Center,
		StartingNumber = 1

	pageNumberStamp.TextState.Font = FontRepository.FindFont("Calibri");
	pageNumberStamp.TextState.FontSize = 8.0F;
	pageNumberStamp.TextState.FontStyle = FontStyles.Italic;

	foreach (var page in mergedDocument.Pages.Cast<Page>())




Thank you for contacting support.

We would like to share with you that the issue has been pending owing to more important and critical issues. However, we have raised the priority of PDFNET-40033, formerly PDFNEWNET-40033, to next level. We will let you know as soon as some significant progress is made in this regard.

Regarding multiple appearances of TOC Title and TOC pages not being counted, a ticket with ID PDFNET-44626 has been logged in our issue management system for further investigation and resolution. Another ticket with ID PDFNET-44627 has been logged for better explanation about IsCountTocPages Property. The ticket IDs have been linked with this thread so that you will receive notifications as soon as the tickets are resolved.

We are sorry for the inconvenience.

So you are saying there have been 4,590+ more important issues since PDFNET-40033 was created?

Regardless, I’m attempting to create my own table of contents page and add it in dynamically. I’ve noticed no bookmarks work when linking to pages that grow beyond 1 page. Seems like a pretty huge bug to me. :frowning_face:


We would like to explain that, not all the issues logged after PDFNET-40033 have been resolved. Some of them were resolved under paid support while some of those tickets were resolved prior to your issue because of their criticality. However, we have raised priority of the ticket and your concerns have been recorded. We appreciate your patience and comprehension in this regard.

This can be relevant to the issue logged previously, PDFNET-40033, but this needs to be investigated separately. Please create a separate topic and share all details along with a sample application reproducing this problem so that we may try to reproduce and investigate it in our environment.