I tried to set the ColumnInfo.ColumnCount property to 2 for a ListSection of type “Table of Contents” and it doesn’t seem to work. Is there a way to list the table of contents in multiple columns?
thanks.
Hi,
We are working over this issue and will reply to you soon.
Hi,
I’ve attached the sample PDF file, can you please take a look over it and confirm if it is the desired behavior that you have been looking for. I’ve created it using the following code snippet and Aspose.Pdf 3.9.0.0
[C#]
Pdf pdf = new Pdf();
Aspose.Pdf.Section sec1 = pdf.Sections.Add();
sec1.ColumnInfo.ColumnCount = 2;
for (int Level = 1; Level <= 61; Level++)
{
Heading heading2 = new Heading(pdf, sec1, Level);
Segment segment2 = new Segment(heading2);
heading2.Segments.Add(segment2);
segment2.Content = "Item Number " + Level.ToString() + "...................." + Level.ToString();
// Add the heading into Table Of Contents.
heading2.IsInList = true;
sec1.Paragraphs.Add(heading2);
}
pdf.Save(@"d:\pdftest\ColumnInfo_test.pdf");
thank you! that is exactly what i was looking for. i will try the code and let you know but from the sample pdf, it looks great. thanks again.
so you’re not using listSection? just regular section? Thanks.
this looks great but i need for it to work with listsection, of type “table of content”. can you help me?
Hi Sponger,
I have logged this problem as PDFNET-8005, a good news is that I have resolved this problem, and we will send you the update ASAP.
Thanks.
Hi Alex,
I have aspose.pdf.dll version 4.0 but this problem still exists. Do you have a fixed version you can send me?
Thanks.
Hi,
Please try the beta version that is attached and code as below. We will publish a new official version in about 3 weeks, it will be reliable than the beta version .
Thanks.
[C#]
Pdf pdf = new Pdf();
Section sec = pdf.Sections.Add();
Heading heading = new Heading(pdf, sec, 1);
Segment segment = new Segment(heading);
heading.Segments.Add(segment);
heading.TextInfo.Alignment = AlignmentType.Center;
segment.Content = "Title";
sec.Paragraphs.Add(heading);
//Create the Table Of Contents. Add it to the pdf like a common Section.
ListSection tocSection = new ListSection(pdf);
tocSection.IsNewPage = false;
tocSection.ListType = ListType.TableOfContents;
tocSection.ColumnInfo.ColumnCount = 2; // when I enable this property, TOC is displayed in 2 columns but is messed up.
tocSection.ColumnInfo.ColumnWidths = "5cm 5cm"; // Even setting the value to "50% 50% " didn't worked
tocSection.ColumnInfo.ColumnSpacing = "10";
pdf.Sections.Add(tocSection);
//Define the format of the four levels' list.
tocSection.ListFormatArray.Length = 62;
Aspose.Pdf.Section sec1 = pdf.Sections.Add();
for (int Level = 1; Level != 62; Level++)
{
Heading heading2 = new Heading(pdf, sec1, Level);
Segment segment2 = new Segment(heading2);
heading2.Segments.Add(segment2);
// heading2.IsAutoSequence = true;
segment2.Content = "Heading - ";
segment2.Content += Level.ToString();
//Add the heading into Table Of Contents.
heading2.IsInList = true;
sec1.Paragraphs.Add(heading2);
}
pdf.Save(@"d:\TOCnew.pdf");