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
The example reads the shop data described in The Business Layer.

GroupDocs.Assembly for Python via .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

from groupdocs.assembly import DataSourceInfo, DocumentAssembler, DocumentAssemblyOptions

assembler = DocumentAssembler()
assembler.options = DocumentAssemblyOptions.REMOVE_EMPTY_PARAGRAPHS
assembler.assemble_document("empty-paragraph.docx", "empty-paragraph-report.docx", DataSourceInfo("dummy", "dummy"))

The following sample file is used in this example: empty-paragraph.docx

Binary file (DOCX, 10 KB)

Download full output

Download

Removing Empty Paragraphs in Presentation Document

from groupdocs.assembly import DataSourceInfo, DocumentAssembler, DocumentAssemblyOptions

assembler = DocumentAssembler()
assembler.options = DocumentAssemblyOptions.REMOVE_EMPTY_PARAGRAPHS
assembler.assemble_document("empty-paragraph.pptx", "empty-paragraph-report.pptx", DataSourceInfo("dummy", "dummy"))

The following sample file is used in this example: empty-paragraph.pptx

Binary file (PPTX, 33 KB)

Download full output

Download

Removing Empty Paragraphs in Email Document

from groupdocs.assembly import DataSourceInfo, DocumentAssembler, DocumentAssemblyOptions

assembler = DocumentAssembler()
assembler.options = DocumentAssemblyOptions.REMOVE_EMPTY_PARAGRAPHS
assembler.assemble_document("empty-paragraph.msg", "empty-paragraph-report.msg", [
    DataSourceInfo("dummy", "dummy"),
    DataSourceInfo("Harbor Lane Provisions <orders@harborlane.example>", "sender"),
    DataSourceInfo(["Quayside Bistro <orders@quaysidebistro.example>", "jonas.weber@harborlane.example"], "recipients"),
    DataSourceInfo("amara.osei@harborlane.example", "cc"),
    DataSourceInfo("Empty paragraph", "subject"),
])

The following sample file is used in this example: empty-paragraph.msg

Binary file (MSG, 16 KB)

Download full output

Download