I am trying to set list level 1 to number style Bullet Disk but it’s not working. Kindly help me.
Please find the below mentioned input and expected output.
Expected_output111.docx (14.3 KB)
ListInput.docx (14.4 KB)
Please find the below mentioned code I tried and also find the below mentioned code output I got
List<Paragraph> listItems = doc.GetChildNodes(NodeType.Paragraph, true).Cast<Paragraph>().Where(p => p.IsListItem && p.ListFormat.ListLevelNumber == 0).ToList();
var hanging = 0.25;
var indentation = 0.25;
foreach (Paragraph listBullet in listItems)
{
listBullet.ListFormat.List = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.BulletDisk);
}
foreach (Paragraph listBullet in listItems)
{
if (listBullet.ParagraphFormat.LeftIndent.ToString() != ConvertUtil.InchToPoint(Convert.ToDouble(hanging)).ToString())
{
listBullet.ParagraphFormat.FirstLineIndent = ConvertUtil.InchToPoint(-Convert.ToDouble(hanging));
// Clear explicit formatting set to heading 1 paragraphs.
doc.GetChildNodes(NodeType.Paragraph, true).Cast<Paragraph>().Where(p => p.IsListItem && p.ListFormat.ListLevelNumber == 0).ToList().ForEach(p =>
{
p.ParagraphFormat.ClearFormatting();
});
}
}
foreach (Paragraph listBullet in listItems)
{
if (listBullet.ParagraphFormat.LeftIndent.ToString() != ConvertUtil.InchToPoint(Convert.ToDouble(indentation)).ToString())
{
listBullet.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(Convert.ToDouble(indentation)) - listBullet.ParagraphFormat.FirstLineIndent;
// Clear explicit formatting set to heading 1 paragraphs.
doc.GetChildNodes(NodeType.Paragraph, true).Cast<Paragraph>().Where(p => p.IsListItem && p.ListFormat.ListLevelNumber == 0).ToList().ForEach(p =>
{
p.ParagraphFormat.ClearFormatting();
});
}
}