Conditional document generation
Generate the contract you need
This template contains optional Intellectual Property and Indemnification sections. Compare how changing only the JSON data changes the final contract.
-
1
Choose the contract data
Include the optional sections or omit their data to remove them from the result.
-
2
Compare the generated document
The merged contract replaces the current editor content. Restore the untouched template whenever you want to compare again.
Two JSON variantsData controls sections
The complete source contains values for both optional clauses. The reduced source omits those properties, allowing the reporting engine to remove the corresponding template regions.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Dynamic Contract Generation
Dynamic sections let one Word-compatible template produce different contract variants. The document structure stays in the template while the JSON data decides which optional regions have content.
Key members
Merge JSON data
MailMerge.MergeJsonData
Reload the merged document
TXTextControl.loadDocument
How it works
Include sections sends the complete data source. Omit sections sends a reduced JSON document without the corresponding properties. The reporting engine evaluates the template's dynamic regions and removes the optional clauses that have no data.
The browser saves the editable template in InternalUnicodeFormat, sends it to the demo-specific controller, and loads the merged document returned by the server. This keeps the template editable until the user chooses a variant.
using var mailMerge = new DocumentServer.MailMerge {
TextComponent = textControl
};
mailMerge.MergeJsonData(jsonData, true);
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