we found out that pdf.save() produces an “file already used by another process” whenever a pdf document having more than 7 chapter level is generated with TOC using aspose pdf. Up to 7 level is works fine
Hi Pascal,
//Instantiate Pdf instance by calling
its empty constructor<o:p></o:p>
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 = 10;
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 ten headings in the section
for (int Level = 1; Level != 11; 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);
}
// save the PDF file
pdf1.Save("c:/pdftest/LargeTOC.pdf");