Hi Shahzad,
Please find the enclosed code , Result O/p and expected Result:
Code
//Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
pdf1.IsBookmarked = true;
//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].Margin.Right = 0;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
tocSection.ListFormatArray[1].Margin.Left = 30;
tocSection.ListFormatArray[1].TextInfo.IsUnderline = true;
tocSection.ListFormatArray[1].TextInfo.FontSize = 10;
tocSection.ListFormatArray[2].Margin.Right = 20;
tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
tocSection.ListFormatArray[3].Margin.Right = 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.TOC = tocSection;
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);
}
Result:
1 this is heading of level 1.......................................0
1.1 this is heading of level 2....................................................0
1.1.1 this is heading of level 3..................................0
1.1.1.1 this is heading of level 4...............................0
3 this is heading of level 1........................................0
3.1 this is heading of level 2.....................................................0
3.1.1 this is heading of level 3...................................0
3.1.1.1 this is heading of level 4................................0
Expected Result:
Result: i.e. Both Side Margins together
1 this is heading of level 1...............................................................0
1.1 this is heading of level 2........................................0
1.2 this is heading of level 4........................................0
3 this is heading of level 1...............................................................0
3.1 this is heading of level 2........................................0
With regards,
Rajat