We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

I am tiring to apply the below property to List Bullet ,List Bullet 2 and List Bullet 3 but its not working

I am tiring to apply the below property to List Bullet , List Bullet 1,List Bullet 2 and List Bullet 3 but its not working. Kindly help me asap.
Please find the input and expected word document.

Input_word_Document123.docx (15.0 KB)
Expeceted_output78.docx (14.9 KB)

Please find the below mentioned code.

Style listBullet = doc.Styles[StyleIdentifier.ListBullet];

listBullet.Font.Size = 11;
listBullet.Font.Name = "Segoe UI";
           

listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.25);
listBullet.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(-0.25) - listBullet.ParagraphFormat.FirstLineIndent;
listBullet.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
listBullet.ParagraphFormat.SpaceAfter = 3;
listBullet.ParagraphFormat.WidowControl = true;
listBullet.ParagraphFormat.TabStops.Add(ConvertUtil.InchToPoint(0.25), TabAlignment.Left, TabLeader.None);

listBullet.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);
listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.25);
listBullet.ParagraphFormat.LeftIndent = -listBullet.ParagraphFormat.FirstLineIndent;

@Princeshivananjappa ListBullet style is not applied to any paragraphs in your source document, so changing this style does not have any effect. In your case formatting to the paragraphs and to text is applied explicitly. So you should set formatting explicitly to the nodes as well. For example see the following code:

Document doc = new Document(@"C:\Temp\in.docx");

List<Paragraph> listItems = doc.GetChildNodes(NodeType.Paragraph, true).Cast<Paragraph>()
    .Where(p => p.IsListItem && p.ListFormat.ListLevel.NumberStyle == NumberStyle.Bullet).ToList();

foreach (Paragraph p in listItems)
{
    // Chnage fonts of the Run nodes inside the paragraph.
    foreach (Run r in p.Runs)
    {
        r.Font.Size = 11;
        r.Font.Name = "Segoe UI";
    }

    // Chnage font of the paragraph break.
    p.ParagraphBreakFont.Size = 11;
    p.ParagraphBreakFont.Name = "Segoe UI";

    p.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);

    p.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.25);
    p.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(-0.25) - p.ParagraphFormat.FirstLineIndent;
    p.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
    p.ParagraphFormat.LineSpacing = 12; // Single line specing
    p.ParagraphFormat.SpaceAfter = 3;
    p.ParagraphFormat.SpaceBefore = 12;
    p.ParagraphFormat.WidowControl = true;
    p.ParagraphFormat.TabStops.Add(ConvertUtil.InchToPoint(0.25), TabAlignment.Left, TabLeader.None);
}

doc.Save(@"C:\Temp\out.docx");

@alexey.noskov Thanks for the quick reply. Above code is working fine for the all list Items. But I want apply the only list level 2 and list level 3. Kindly help me asap.
Please find the below Input and expected word document.
Expeceted_output78.docx (15.3 KB)
Input_word_Document123.docx (14.9 KB)

@Princeshivananjappa As I can see your input and expected output documents differs only by the font applied to the list items. So you can simplify the above provided code like this to get the desired output:

Document doc = new Document(@"C:\Temp\in.docx");

List<Paragraph> listItems = doc.GetChildNodes(NodeType.Paragraph, true).Cast<Paragraph>()
    .Where(p => p.IsListItem && p.ListFormat.ListLevel.NumberStyle == NumberStyle.Bullet).ToList();

foreach (Paragraph p in listItems)
{
    // Chnage fonts of the Run nodes inside the paragraph.
    foreach (Run r in p.Runs)
    {
        r.Font.Size = 11;
        r.Font.Name = "Segoe UI";
    }

    // Chnage font of the paragraph break.
    p.ParagraphBreakFont.Size = 11;
    p.ParagraphBreakFont.Name = "Segoe UI";
}

doc.Save(@"C:\Temp\out.docx");

@alexey.noskov Kindly understand my concern. I want to apply the property individually for List Bullet, List Bullet 2, List Bullet 3.

Style listBullet = doc.Styles[StyleIdentifier.ListBullet];

listBullet.Font.Size = 11;
listBullet.Font.Name = "Segoe UI";


listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.25);
listBullet.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(-0.25) - listBullet.ParagraphFormat.FirstLineIndent;
listBullet.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
listBullet.ParagraphFormat.SpaceAfter = 3;
listBullet.ParagraphFormat.WidowControl = true;
listBullet.ParagraphFormat.TabStops.Add(ConvertUtil.InchToPoint(0.25), TabAlignment.Left, TabLeader.None);

listBullet.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);
listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.25);
listBullet.ParagraphFormat.LeftIndent = -listBullet.ParagraphFormat.FirstLineIndent;

ListBullet 2:

Style listBullet = doc.Styles[StyleIdentifier.ListBullet1];

listBullet.Font.Size = 15;
listBullet.Font.Name = "Segoe UI";


listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.5);
listBullet.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(-0.5) - listBullet.ParagraphFormat.FirstLineIndent;
listBullet.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
listBullet.ParagraphFormat.SpaceAfter = 13;
listBullet.ParagraphFormat.WidowControl = true;
listBullet.ParagraphFormat.TabStops.Add(ConvertUtil.InchToPoint(0.5), TabAlignment.Left, TabLeader.None);

listBullet.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);
listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.5);
listBullet.ParagraphFormat.LeftIndent = -listBullet.ParagraphFormat.FirstLineIndent;

ListBullet 3:

Style listBullet = doc.Styles[StyleIdentifier.ListBullet2];

listBullet.Font.Size = 14;
listBullet.Font.Name = "Segoe UI";


listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.25);
listBullet.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(-0.25) - listBullet.ParagraphFormat.FirstLineIndent;
listBullet.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
listBullet.ParagraphFormat.SpaceAfter = 16;
listBullet.ParagraphFormat.WidowControl = true;
listBullet.ParagraphFormat.TabStops.Add(ConvertUtil.InchToPoint(0.25), TabAlignment.Left, TabLeader.None);

listBullet.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);
listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-0.25);
listBullet.ParagraphFormat.LeftIndent = -listBullet.ParagraphFormat.FirstLineIndent;

@Princeshivananjappa As I already mentioned earlier list formatting in your documents is not applied via styles, so changes made to ListBullet, ListBullet1 and ListBullet3 have no effect.
In your case you should change the explicit formatting as I suggested earlier. If you need to apply different formatting to different list levels, you can use ListFormat.ListLevelNumber property to get list level number of the paragraph.