Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Nov 05, 2019 11:54 am

After apply paragraph to list format, it turn out well except the number font style that not follow the ParagraphStyle.
Is there a way to force the list number style to adopt the style of paragraph or specific style?

here is my code
Code: Select all
ParagraphStyle s2 = new ParagraphStyle(doc);
s2.Name = "CordiaUPCNormal";
s2.CharacterFormat.FontName = "CordiaUPC";
s2.CharacterFormat.FontSize = 16;
doc.Styles.Add(s2);

Paragraph Para11 = section1.AddParagraph();
Para11.Format.LeftIndent =20;
TextRange textRange1 = Para11.AppendText(child.Content_Text);
textRange1.CharacterFormat.TextColor = child.color;
Para11.Format.HorizontalAlignment = HorizontalAlignment.Left;
Para11.ApplyStyle(s2.Name);
Para11.Format.BeforeSpacing = 12;
Para11.ListFormat.ListLevelNumber = 1
Para11.ListFormat.ApplyStyle("levelstyle");

thamanoon.k
 
Posts: 3
Joined: Tue Oct 29, 2019 8:41 am

Wed Nov 06, 2019 7:50 am

Hi,

Thanks for your inquiry.
You could create a list style which is same as paragraph style, and then apply the style to list.
Code: Select all
            ListStyle listStyle = new ListStyle(doc, ListType.Numbered);
            listStyle.Name = "levelstyle";
            listStyle.Levels[0].PatternType = ListPatternType.Arabic;
            //set the font name
            listStyle.Levels[0].CharacterFormat.FontName = "CordiaUPC";
            //set the font size
            listStyle.Levels[0].CharacterFormat.FontSize = 16;

            listStyle.Levels[1].PatternType = ListPatternType.Arabic;
            //set the font name
            listStyle.Levels[1].CharacterFormat.FontName = "CordiaUPC";
            //set the font size
            listStyle.Levels[1].CharacterFormat.FontSize = 16;

            doc.ListStyles.Add(listStyle);

            //apply the list style to the list
            Para11.ListFormat.ApplyStyle("levelstyle");


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Nov 06, 2019 11:05 am

Thank you, It works! :D

thamanoon.k
 
Posts: 3
Joined: Tue Oct 29, 2019 8:41 am

Thu Nov 07, 2019 1:27 am

Hi,

Thanks for your feedback.
If there is any question, please feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc