Mail Merge
When many documents share one layout and differ only in their data, such as invoices, letters or reports, mail merge produces them from a template and a data source. Three tutorials walk through one invoice in a WPF ribbon window: the template is designed with the Reporting tab of the ribbon, JSON data fills its merge fields, and a merge block turns the invoice items into table rows.
Choose a Tutorial
| Tutorial | You learn to | Main members |
|---|---|---|
| Create a Template | Add the Reporting tab in XAML, give it sample data, insert merge fields and save the template | RibbonReportingTab, DataSourceManager.LoadJson, MergeField |
| Merge Data into Fields | Merge JSON data into the template in the background, show the result, save it as PDF and find fields without data | MailMerge, MergeJsonData, FieldMerged |
| Add Repeating Merge Blocks | Repeat a table row for each item, with the ribbon or in code, and merge business objects | InsertMergeBlock, InsertMergeBlockDialog, MergeObject |
The tutorials share the data invoice.json and the template invoice.docx, so work through them in the order of the table.

Before You Start
- Complete Create a WPF Ribbon Application. The tutorials add the Reporting tab to its ribbon and buttons to its window.
- Mail merge and the ribbon are part of the Professional and Enterprise editions. See Editions and Feature Availability.
- MailMerge in the Overview introduces the component, its data sources and the reporting user interface.
What Is Specific to WPF
MailMerge, DataSourceManager and the merge field classes are the same as in the other TX Text Control products. In a WPF window, the differences are in the user interface:
- The Reporting tab is a
RibbonReportingTabin theRibbonof WPF. It is declared in XAML and connected by name in theRibbonReportingTabattribute of theTextControl. - The field navigator is a
Sidebarthat the tab'sFieldNavigatorSidebarattribute names. Without it, the tab hides its Field Navigation button. - The dialog boxes for merge blocks and data relations are classes of the namespace
TXTextControl.DocumentServer.WPF, such asInsertMergeBlockDialog, which your code can open as well.
After These Tutorials
- Mail Merge and Reporting: data sources, fields, blocks, conditions, formatting and events in detail.
- PDF Processing: add PDF options, forms and signatures to the merged documents.
- Mail Merge Examples: complete WPF applications with the Reporting tab.