Hi Nausherwan,
your code works, I can confirm this. The problem appear when a toc is added.
Here is the snippet:
Aspose.Pdf.Generator.Pdf pdf1 = new Pdf();
pdf1.BookmarkLevel = 6;
ListSection TOCSection1 = new ListSection(pdf1);
TOCSection.ListType = ListType.TableOfContents;
Text SText1 = new Text("Table Of Content1");
TOCSection1.Title = SText1;
TOCSection1.Title.TextInfo.Alignment = AlignmentType.Center;
TOCSection1.Title.TextInfo.FontSize = 20;
pdf1.Sections.Add(TOCSection1); //without this line all everything is ok ...
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//error ifmax >4!!!!
int max=5;
for (int Level = 1; Level != max; 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 = "this is heading of level ";
segment2.Content += Level.ToString();
//Add the heading into Table Of Contents.
heading2.IsInList = true; sec1.Paragraphs.Add(heading2);
}
pdf1.Save(Server.MapPath("~//temp//") + "TOC.Pdf");
Any idea ?
Best regards
Kagel