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

Free Support Forum - aspose.com

Longer text in TOC causing stackoverflow exception

Hi,

I am facing an issue when I try to create a PDF with TOC with japanese content. The text I need as part of the table of content is ‘東京エレクトロンデ(2760.T) 08年3月期はC・N事業フル貢献で増収増益。親会社の売り出しで上場廃止を回避、1部指定替えの条件はすべてクリアか’ .

I am always getting stackoverflow exception because the content is large for TOC. When I remove the last four characters I am able to successfully create the PDF with TOC.

Can you please look into this issue at the earliest? We have this issue in our live application.

Let me know if you need any additional details.

Thanks,
Naresh

Hello Naresh,

Thanks for using our products.

I have tested the scenario using Aspose.Pdf for .NET 6.2.0 and I am unable to notice any problem. I have used the following code snippet to generate the PDF document. Can you please share the code snippet that you are using so that we can test it at our end. We apologize for your inconvenience.

[C#]

//Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
//Create a list section
Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents");
//Set its list type as table of of contents
tocSection.ListType = Aspose.Pdf.Generator.ListType.TableOfContents;
//Add the list section to the sections collection of the Pdf document
pdf1.Sections.Add(tocSection);

//Define the format of the four levels list by setting the left margins and
//text format settings of each level
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;

//Create a section in the Pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Add four headings in the section
for (int Level = 1; Level != 5; Level++)
{
Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, Level);
Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);
heading2.Segments.Add(segment2);
heading2.IsAutoSequence = true;
segment2.Content = "東京エレクトロンデ(2760.T) 08年3月期はC・N事業フル貢献で増収増益。親会社の売り出しで上場廃止を回避、1部指定替えの条件はすべてクリアか'条件はすべてクリアか' .";
segment2.Content += Level.ToString();
//Add the heading into Table Of Contents.
heading2.IsInList = true;
sec1.Paragraphs.Add(heading2);
}

pdf1.SetUnicode();
pdf1.IsAutoFontAdjusted = true;
pdf1.Save("d:/pdftest/TOC-Issue.pdf");

Can you please try the same example that you have provided with PDF version 5.3?

Thanks.

Hello Naresh,

Can you please share the exact link of forum thread containing said code snippet, so that we test the scenario with correct code sample.