Dynamic content
Remove sections without data
Merge the report and observe how complete template regions disappear when their corresponding JSON arrays are empty or missing.
Data-driven structureKeep only populated regions
Empty arrays remove their complete merge blocks instead of leaving blank content.
ConditionalDecisionData presence
ScopeComplete block
SettingRemoveEmptyBlocks
OutputClean layout
Template structureUnderstand the current template
Explore its merge fields, repeating blocks, and nested structure in an interactive template map.
Inspector
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Let data control document structure
Conditional sections are regular merge blocks whose content is retained only when matching records exist. They can contain complete clauses, tables, images, or any other document content.
RemoveEmptyBlocks removes both the block markers and their enclosed content when no data is available, avoiding blank placeholders in the final document.
API used
MailMerge.RemoveEmptyBlocks
Key members
RemoveEmptyBlocks removes complete unmatched template ranges, including their enclosed paragraphs, tables, and images.
using var mailMerge = new MailMerge
{
TextComponent = textControl,
RemoveEmptyBlocks = true
};
mailMerge.LoadTemplate(templatePath, FileFormat.InternalUnicodeFormat);
mailMerge.MergeJsonData(File.ReadAllText(dataPath));
How it works
The controller enables RemoveEmptyBlocks before merging the JSON. MailMerge evaluates each named block against the data hierarchy and removes unmatched regions during expansion.
NuGet packages
TXTextControl.TextControl.Core.SDK
34.0.4
Provides the core document model and server-side document processing APIs.
dotnet add package TXTextControl.TextControl.Core.SDK --version 34.0.4
Displays supported document and PDF formats in the browser.
dotnet add package TXTextControl.Web.DocumentViewer --version 34.2.0