The example.docx have many empty bullet points how to delete them with programming?
example.zip (10.2 KB)
foreach (Paragraph paragraph in doc.GetChildNodes(NodeType.Paragraph, true))
{
if (paragraph.GetText().Trim().ToUpper().Contains(" "))
{
paragraph.Remove();
}
}
I know to do this kind of thing… But what should i check after GetText()?
@Iamaditya,
You can first check if the current Paragraph belongs to a List and then after checking emptiness, remove it:
foreach (Paragraph paragraph in doc.GetChildNodes(NodeType.Paragraph, true))
{
if (paragraph.IsListItem)
{
if (string.IsNullOrEmpty(paragraph.ToString(SaveFormat.Text).Trim()))
{
paragraph.Remove();
}
}
}
Thanks for the help @awais.hafeez sir.
Keep up the good work.