RemoveParentParagraphs and empty paragraphs should remain

According to new rules of option RemoveParentParagraphs (copied from documentation below) the paragraphs containing a space are removed. But we need to leave such paragraphs. Which symbol can we insert to leave the paragraph alive in the document?
Best regards, Evgeniy
This option is generally similar to the RemoveParentParagraphs property which is now obsolete. However, the option is slightly improved in comparison to the property. The property only treated a paragraph as empty if it had no child nodes at all, while the new option removes a paragraph even if it contains whitespace characters like spaces or tabs. Previously, a paragraph with a space character in it would not be removed. Now, it will.

To add some clarifications:
In previous versions we could set “null” values and spaces " " to fields.
In the first case the paragraphs were removed but for spaces they were left in document that was absolutely correct.
Now starting from version. 10.8.0 such paragraphs are removed as well.
- Evgeniy

Any comment here? Could you suggest a solution?
Best regards, Evgeniy

Hi Evgeniy,

Thank you for inquiry. Sorry because of delay, you can customize empty paragraph removals by following code snippet:

// Remove empty paragraph from document
// Load document
Document doc = new Document("in.doc");
RemoveEmptyParagraph parRem = new RemoveEmptyParagraph();
public class RemoveEmptyParagraph: DocumentVisitor

    public override VisitorAction VisitParagraphStart(Paragraph paragraph)
        // Check the string and customize according your need
        if (paragraph.HasChildNodes)

        return VisitorAction.Continue;

Hope this will help. In case of any ambiguity, please let me know.

Hi Imran,
Thanks for the tip, but this does not help with the problem.
Let me explain one more. We have two fields: the first has value " " and the second “”. In old versions of Aspose.Words the paragraph for first field left in the document and only the second was deleted. Now option REMOVE_EMPTY_PARAGRAPHS deletes both paragraphs that is unacceptable for our case.
This is very important as we could handle it in Java code and set value to " " if we wanted to keep the paragraph in the document.

document.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS |
    MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS |
String names[] = new String[]
String values[] = new String[]
    " ",
document.getMailMerge().execute(names, values);

Best regards, Evgeniy

Hi Evgeniy,

Thanks for this additional information.

I think the code on this thread might be useful to you:

You can use this code in place of the RemoveEmptyParagraphs option.


Hi Adam,
Thanks a lot for the link. I think such receipts should be placed to some cook book of Aspose.Words. That would save a lot of time for customers.
Also maybe in future versions you can implement more options (e.g. REMOVE_ONLY_EMPTY_FIELDS) to handle this without additional code snippets.
Best regards, Evgeniy

Hi Evgeniy,

It’s great things are working now. Yes, we often take helpful code snippets from the forums that are used a lot by our customers and add them to the documentation. I will consider adding this particular snippet to the documentation.

Regarding your request for a built-in option for this behavior, I have linked your request to the appropriate issue. You will be informed as soon as it’s implemented.