Hi
I need to identify bulleted list in the document and then replace the bullets with default Numbered List.
Thanks
Timothy Delixus
This message was posted using Page2Forum from Aspose.Words for .NET - Documentation
Hi
I need to identify bulleted list in the document and then replace the bullets with default Numbered List.
Thanks
Timothy Delixus
This message was posted using Page2Forum from Aspose.Words for .NET - Documentation
Hello
Thanks for your request. Please try using the following code:
Document doc = new Document("C:\\Temp\\in.doc");
// Reset indents of list items.
NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
foreach(Paragraph paragraph in paragraphs)
{
if (paragraph.IsListItem)
{
// If paragraph is an item of bulleted list, we should specify NumberStyle Arabic.
if (paragraph.ListFormat.ListLevel.NumberStyle == NumberStyle.Bullet)
{
paragraph.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
paragraph.ListFormat.ListLevel.NumberFormat = "\u0000";
}
}
}
doc.Save("C:\\Temp\\out.doc");
Please let me know in case of any issues. I will be glad to help you.
Best regards,
Hi
I replaces all the bullets into Numbered Lists.
I want to select a set of bulleted list. Check for some condition ,if condition satisfies replace bullets to numbers else leave bullets as it is.
Also, as soon as i replace first bullet it replaces all the bullets to Numbered list.
Thanks
Timothy Delixus
Hello
Thanks for your request. In this case please try using the following code:
Document doc = new Document("C:\\Temp\\in.doc");
// Create a list based on one of the Microsoft Word list templates.
List list = doc.Lists.Add(ListTemplate.NumberDefault);
// Reset indents of list items.
NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
foreach(Paragraph paragraph in paragraphs)
{
if (paragraph.IsListItem)
{
// If paragraph is an item of bulleted list, we should specify NumberStyle Arabic.
if (paragraph.ListFormat.ListLevel.NumberStyle == NumberStyle.Bullet)
if (yourCondition == true)
{
paragraph.ListFormat.List = list;
}
}
}
doc.Save("C:\\Temp\\out.doc");
Best regards,