Aspose PDF TOC

Good Day Everyone,


How to do i customize the table of contents.
My page numbers are displaying like C1,C2,C3, X1,X2,X3, Z1,Z2,Z3 … something like this but when i add TOC then in the index page then page numbers are displaying in number format.

How do i display page number in text format)… Please find the below example.
Table of Contents
Page A-----------------------------A1
Page D----------------------------D4
Page E------------------------ E3
Page X ------------------------- X4.

Please advise how do i accomplish.

Thanks in advance.

Hi,


Thank you for contacting support. Kindly send us your source PDF and code which you are using to add the table of contents. We will take a closer look, and then advise you appropriately. Your response is awaited.

Here is the code.
I'm merging the pdf files and assigning page numbers(like p1, p2, a2,a5,d6...etc). After that I'm creating table of contents.

var tocPage = pdfDocument1.Pages.Insert(1);
var tocInfo = new TocInfo();
var title = new TextFragment("Table Of Contents");
title.TextState.FontSize = 20;
title.TextState.FontStyle = FontStyles.Bold;
tocInfo.Title = title;
tocPage.TocInfo = tocInfo;

var pageNum = 0;

for (var i = 0; i < pagetitles.Length; i++)
{
// Create Heading object
Aspose.Pdf.Heading heading2 = new Aspose.Pdf.Heading(1);
TextSegment segment2 = new TextSegment();


heading2.TocPage = tocPage;
heading2.Segments.Add(segment2);
if (i == 0)
{
pageNum = 2;
}
else
{
pageNum = pageNum + pageNumbers[i];
}
// Specify the destination page for heading object
heading2.DestinationPage = pdfDocument1.Pages[pageNum];
// Destination page
heading2.Top = pdfDocument1.Pages[pageNum].Rect.Height;

heading2.Text = pagetitles[i];

// Destination coordinate
// segment2.Text = pagetitles[i];

// Add heading to page containing TOC
tocPage.Paragraphs.Add(heading2);
}

Hi,


Thank you for contacting support. We recommend our clients to share the complete details of the use case. It helps us to address the problem as per the requirement. As we understand, you can generate a PDF with the same layout of TOC as you shared in the first post, but the only problem is that it is in the number format. We need to replicate this issue in our environment, and then we can share our findings with you. Kindly share the input and output PDFs, complete code and an expected output PDF. Your response is awaited.

I’m not sure if you are able to understand my question or not.


I just want to display page numbers in table of contents page in below format.

Introduction -------------------- P3
About US ----------------------- P4
Contact US --------------------- P10

When I try to use toc, page numbers are displaying in just numbers like 1 , 2, 3.

So i’m not sure what is so hard to replicate this issue.

Here is the pdf merging part.

Document pdfDocument1 = pdfDocument[0];
var pageNumbers = new int[pdfDocument.Length];
pageNumbers[0] = pdfDocument1.Pages.Count;
for (var i = 1; i < pdfDocument.Length; i++)
{
pdfDocument1.Pages.Add(pdfDocument[i].Pages);
}



Hi,


Thank you for the inquiry. We are working over your query and will get back to you soon.

Hi,


Thank you for being patient. There is no direct way to customize the page numbering in the TOC. We have logged an enhancement under the ticket ID PDFNET-42824 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.

The issues you have found earlier (filed as PDFNET-42824) have been fixed in Aspose.PDF for .NET 19.11.