Hi
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. I modified my code from the previous post. Please try using the following code:
// Remove empty paragraph from document
public void Test037()
{
// Load document
Document doc = new Document(@"Test037\in.doc");
RemoveEmptyParagraph parRem = new RemoveEmptyParagraph();
doc.Accept(parRem);
doc.Save(@"Test037\Out.doc");
}
public class RemoveEmptyParagraph : DocumentVisitor
{
public override VisitorAction VisitParagraphStart(Paragraph paragraph)
{
if (string.IsNullOrEmpty(paragraph.ToTxt().Trim()))
{
if (paragraph.NextSibling != null && paragraph.NodeType == NodeType.Paragraph && string.IsNullOrEmpty(paragraph.NextSibling.ToTxt().Trim()))
paragraph.Remove();
}
return VisitorAction.Continue;
}
}
Hope this helps.
Best regards,