Feature request: Aspose.Words - strip empty text/paragraphs

There is an option to remove empty paragraphs in Aspose.Words that affects whole document and requires code changes. Would be nice to have a template tag to apply it only to specific parts of a document, and this would provide control from a document itself. Something similar other templating engines have, for example smarty’s “strip” tag {strip} | Smarty

For example, if Paragraph2 and Paragraph3 would be removed if empty



You can remove the empty paragraph between specified tag by iterating over paragraphs collection. You can check the text of paragraph by using Node.ToString method. Please remove the paragraph node using Node.Remove method.

If you face any issue, please ZIP and attach your input and expected output documents. We will then provide you more information about your query along with code.

From code yes. In some cases it would be more convenient to let users who create templates decide which template needs empty paragraphs removal and which doesn’t.

Anyway, that was just a suggestion. Not sure how widely such a feature would be used among Aspose customers.


In such cases, you need to iterate over paragraphs collection and remove the desired paragraph. If you face any issue while using Aspose.Words, please let us know.