Hierarchical data
Generate a nested report
Merge a customer, its orders, and each order's line items into nested repeating regions. Compare the compact template with the expanded result.
Nested JSONExpand the report hierarchy
Customer, order, and line-item arrays drive independent repeating regions.
3 levelsTemplateNested blocks
DataHierarchical JSON
ProcessingServer-side
ResultExpanded report
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
Repeat any document structure
A merge block is a named template range associated with an array in the data source. Its content can include table rows, paragraphs, images, or other nested blocks.
The outer Orders block repeats once per order. Inside it, OrderItems repeats independently and resolves product fields from each child object.
API used
MailMerge.MergeJsonData
Key members
MergeJsonData preserves nested arrays so matching merge blocks can repeat independently at every hierarchy level.
using var textControl = new ServerTextControl();
textControl.Create();
using var mailMerge = new MailMerge
{
TextComponent = textControl,
RemoveEmptyBlocks = true
};
mailMerge.LoadTemplate(templatePath, FileFormat.InternalUnicodeFormat);
mailMerge.MergeJsonData(File.ReadAllText(dataPath));
mailMerge.SaveDocumentToMemory(
out byte[] document,
BinaryStreamType.InternalUnicodeFormat,
new SaveSettings());
How it works
The controller loads the fixed TX template, reads hierarchical JSON from the same feature folder, removes unmatched empty blocks, and saves the fully expanded result in memory.
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