Removing Empty Paragraphs

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Assembly MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-assembly -- dnx GroupDocs.Assembly.Mcp --yes
Folders, licensing and more →

Note
This feature is supported by version 18.10. or greater.
Note
The code uses some of the objects defined in The Business Layer.

GroupDocs.Assembly for .NET API supports the removal of paragraphs becoming empty after template syntax tags are removed or replaced with empty values. A new member RemoveEmptyParagraphs is added to DocumentAssemblyOptions. When this new option is applied to DocumentAssembler options through DocumentAssembler.Options, the engine additionally removes empty paragraphs.

Removing Empty Paragraphs in Word Processing Document

Download

Removing Empty Paragraphs in Presentation Document

Download

Removing Empty Paragraphs in Email Document

Download

Removing Empty Paragraphs in Spreadsheet and Plain Text Documents

Note
This feature is supported by version 26.11 or greater.

In spreadsheet templates and plain text documents, a paragraph is a line of text: a line of a cell’s text, or of a text document, that becomes empty after template tags are removed or replaced with empty values is removed together with its line break. Tags such as <<if>> and <<foreach>> written on their own lines no longer leave empty lines behind.

DocumentAssembler assembler = new DocumentAssembler();
assembler.Options = DocumentAssemblyOptions.RemoveEmptyParagraphs;
assembler.AssembleDocument("Empty paragraph.txt", "result.txt", new DataSourceInfo("dummy", "dummy"));

Template:

Prefix
<<[""]>>
Suffix

Prefix
<<if [false]>>
Text to be removed
<</if>>
Suffix

Result:

Prefix
Suffix

Prefix
Suffix

The same template text in a cell of a spreadsheet gives the same result within the cell. Example: RemoveEmptyParagraphs.cs, which assembles the DOCX, PPTX, MSG, XLSX and TXT variants.

Download