Listsection title fontsize- bold

Hi, Before upgrading to the current version from one that was about a year old, I used code like this to set the fontname and size of the title:

ListSection tocSection = new ListSection(“TABLE OF CONTENTS”);
Text text = tocSection.Paragraphs[0] as Text;
text.Segments[0].TextInfo.FontName = “Helvetica-Bold”;

text.Segments[0].TextInfo.FontSize = 16;
text.Margin.Bottom = 20;


But the Paragraphs[0] no longer exists. How can I set the fontsize,name and margin of the Title of the section?

Thanks,
Jerry Howard

Hi,

Thank you for considering Aspose.

First call the Pdf.BindXml method and after that you can loop through all the Pdf in the Section. When you get your required paragraph then set the TextInfo. Please refer to following code:

foreach (Aspose.Pdf.Section sec in pdf.Sections)

{

foreach (Aspose.Pdf.Paragraph para in sec.Paragraphs)

{

if (para is Text)

{

foreach (Segment seg in text.Segments)

{

if (seg.TextInfo.FontName != null )

seg.TextInfo.FontName = "Helvetica-Bold";

}

}

}

}

Thanks.

To clarify, I have already done the bindXml at this point when I am creating a TOC. The problem is that the Title of the TOC list section doesn't seem to be in a paragraph. It used to be in paragraph 0, but now where is it? When I do this:

ListSection tocSection = new ListSection("TABLE OF CONTENTS");

After that statement is executed, tocSection.Paragraphs[0] doesn't exist, so the strategy you mention still wouldn't find it. I used to be able to change the font, etc. of the title by using Paragraphs[0] of that section. Now I can't.

Jerry



Ok, I figured it out. The Title is its own separate text paragraph that is not part of the paragraphs collection for the section, so this works:

//Table of contents<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

ListSection tocSection = new ListSection("TABLE OF CONTENTS");

Text text = tocSection.Title;

text.Segments[0].TextInfo.FontName = "Helvetica-Bold";

text.Segments[0].TextInfo.FontSize = 16;

text.Margin.Bottom = 20;

Jerry