Hi Nayyar,
Sorry for responding late, here is Table of Content code we are trying.
String outFile = "C:/Test.pdf";
Pdf pdf = new Pdf();
com.aspose.pdf.Document pdfDocument1 = new com.aspose.pdf.Document(outFile);
//Create a list section
ListSection tocsec = new ListSection("Table of contents");
//Add the list section to the sections collection of the Pdf document
pdf.getSections().add(tocsec);
// Get the Text value of the title of ListSection.
Text text = tocsec.getTitle();
// set the font name for TOC title text.getSegments().getSegment(0).getTextInfo().setFontName("Helvetica");
// set the font size information for TOC title
text.getSegments().getSegment(0).getTextInfo().setFontSize(16);
// set the Bottom margin information for TOC title
text.getMargin().setBottom(20);
//Set the length of list levels to 4
tocsec.getListFormatArray().setLength(4);
// Set left margin information for first level list item
tocsec.getListFormatArray().getListLevelFormat(0).setLeftMargin(0);
// Set Font Name information for first level list item
tocsec.getListFormatArray().getListLevelFormat(0).getTextInfo().setFontName("Helvetica");
// Set Font Size information for first level list item
tocsec.getListFormatArray().getListLevelFormat(0).getTextInfo().setFontSize(24);
// Set left margin information for Second level list item
tocsec.getListFormatArray().getListLevelFormat(1).setLeftMargin(5);
// Set Font Name information for Second level list item
tocsec.getListFormatArray().getListLevelFormat(1).getTextInfo().setFontName("Helvetica");
// Set Font Size information for Second level list item
tocsec.getListFormatArray().getListLevelFormat(1).getTextInfo().setFontSize(20);
// Set Font color information for Second level list item
tocsec.getListFormatArray().getListLevelFormat(1).getTextInfo().setColor(new aspose.pdf.Color("Red"));
// Set left margin information for Third level list item
tocsec.getListFormatArray().getListLevelFormat(2).setLeftMargin(10);
// Set Font Name information for Third level list item
tocsec.getListFormatArray().getListLevelFormat(2).getTextInfo().setFontName("Helvetica");
// Set Font Size information for Third level list item
tocsec.getListFormatArray().getListLevelFormat(2).getTextInfo().setFontSize(14);
//tocsec.getListFormatArray().getListLevelFormat(2).getTextInfo().setIsTrueTypeFontBold(true);
// Set left margin information for Fourth level list item
tocsec.getListFormatArray().getListLevelFormat(3).setLeftMargin(15);
// Set Font Name information for Fourth level list item
tocsec.getListFormatArray().getListLevelFormat(3).getTextInfo().setFontName("Helvetica");
// Set Font Size information for Fourth level list item
tocsec.getListFormatArray().getListLevelFormat(3).getTextInfo().setFontSize(10);
//tocsec.getListFormatArray().getListLevelFormat(3).getTextInfo().setIsTrueTypeFontBold(true);
//Set its list type as table of of contents
tocsec.setListType(ListType.TableOfContents);
// Create a section in the Pdf document
Section sec = pdfDocument1.getSections().add();
//Add four headings in the section
for (int level = 1; level != 5; level++)
{
// Create a heading object with heading level according to loop iterative variable
Heading heading2 = new Heading(pdfDocument1, sec, level);
// Create a segment object and pass heading object as argument
Segment seg2 = new Segment(heading2);
// add the segment to segments collection of heading object
heading2.getSegments().add(seg2);
//set the value that indicates that the number of the heading is added in automatic sequence
heading2.setIsAutoSequence(true);
// set the content value for segment object
seg2.setContent("this is heading of level");
// Specify that the heading paragraph is used as a list item
heading2.setIsInList(true);
// add heading to paragraphs collection of section
sec.getParagraphs().add(heading2);
}
//Save the resultant PDF
pdf.save("D:Resultant.pdf");
I am getting compilation error for this method : getListLevelFormat(X)
Thanks
Sateesh