Personalized document
Merge an address into the template
Change the recipient data and create a personalized document. The browser sends data only; the template and merge operation stay on the server.
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
Separate templates from application data
MailMerge combines a reusable Word-compatible template with business data. Designers control the document layout while application code supplies strongly typed values at runtime.
The merge is performed in memory with ServerTextControl. No browser editor, temporary document, or client-side template processing is required.
API used
MailMerge.MergeObject
Key members
MailMerge receives a ServerTextControl as its text component and maps object properties to fields in the loaded template.
using var textControl = new ServerTextControl();
textControl.Create();
using var mailMerge = new MailMerge
{
TextComponent = textControl
};
mailMerge.LoadTemplate(templatePath,
FileFormat.WordprocessingML);
mailMerge.MergeObject(new
{
firstname = request.FirstName.Trim(),
name = request.LastName.Trim(),
company = request.Company.Trim(),
street = request.Street.Trim(),
zip = request.CityAndPostalCode.Trim()
});
mailMerge.SaveDocumentToMemory(out byte[] document,
BinaryStreamType.InternalUnicodeFormat,
new SaveSettings());
How it works
The endpoint validates the request, loads its fixed DOCX template, maps request properties to matching merge-field names, and returns the resulting Internal Unicode Format document as Base64.
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