Removing Paragraphs Containing Only Template Syntax Tags

Contents
[ ]

While building a report, some paragraphs containing only template syntax tags can become empty after the tags are removed or replaced with empty values. To remove such paragraphs from the report, you can apply the ReportBuildOptions.RemoveEmptyParagraphs option as shown in the following example.

ReportingEngine engine = new ReportingEngine();
engine.Options |= ReportBuildOptions.RemoveEmptyParagraphs;
engine.BuildReport(...);

The difference in the engine’s behavior when the option is applied and not applied is illustrated by the following examples.

Example 1

Template document

Prefix
<<[""]>>
Suffix

Result document without ReportBuildOptions.RemoveEmptyParagraphs applied

Prefix

Suffix

Result document with ReportBuildOptions.RemoveEmptyParagraphs applied

Prefix
Suffix

Example 2

Template document

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

Result document without ReportBuildOptions.RemoveEmptyParagraphs applied

Prefix

Suffix

Result document with ReportBuildOptions.RemoveEmptyParagraphs applied

Prefix
Suffix

Example 3

Note – In this example, persons is assumed to be a data table having a field Name.

Template document

Prefix
<<foreach [in persons]>>
<<[Name]>>
<</foreach>>
Suffix

Result document without ReportBuildOptions.RemoveEmptyParagraphs applied

Prefix

John Doe

Jane Doe

John Smith

Suffix

Result document with ReportBuildOptions.RemoveEmptyParagraphs applied

Prefix
John Doe
Jane Doe
John Smith
Suffix