Reusable document components
Compose a document from sub-templates
The main template contains an IncludeText field. Merge it to resolve the referenced sub-template and then inspect the resulting document in the editor.
1Review the main template
The editor shows the main document and its IncludeText placeholder before the component is resolved.
2Resolve the sub-template
The server locates the referenced document, merges its fields, and loads the composed result back into the editor.
IncludeText is compositionReusable content
Use sub-templates for reusable clauses, headers, product sections, or complete document fragments while keeping the main template small.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Merging Sub-Templates
IncludeText fields let a reporting template reference reusable TX Text Control documents. The server resolves those references before it completes the merge.
Key members
Resolve referenced templates
MailMerge.SearchPath
Merge the composed document
MailMerge.MergeJsonData
Reload the result
TXTextControl.loadDocument
How it works
The browser saves the current main template and sends it to the demo-specific controller. The controller configures MailMerge.SearchPath, resolves the referenced sub-template, merges the sample JSON data into both documents, and returns the composed internal document.
After the response arrives, TXTextControl.loadDocument replaces the placeholder view with the final content. In a production application, the search path can point to a controlled template repository or tenant-specific document store.
using var mailMerge = new DocumentServer.MailMerge {
TextComponent = textControl,
SearchPath = templateFolder
};
mailMerge.MergeJsonData(jsonData);
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
Provides the browser-based TX Text Control document editor and JavaScript API.
dotnet add package TXTextControl.Web --version 34.4.0
TXTextControl.Web.DocumentEditor.Backend
34.4.0
Hosts the WebSocket-based backend used by the browser document editor.
dotnet add package TXTextControl.Web.DocumentEditor.Backend --version 34.4.0