Creating Mail Merge Templates Including a Preview Functionality
Thanks to the new FieldAdapter class, MS Word compatible merge fields can be inserted easily into a document. Using our Windows Forms version, a template designer can be easily built and deployed royalty-free. In our shipped samples, we demonstrate how to create templates by inserting the fields directly using the ApplicationField collection. This article describes how to create templates using the adapter fields. Additionally, it shows how to preview the template with the real data coming…

Thanks to the new FieldAdapter class, MS Word compatible merge fields can be inserted easily into a document. Using our Windows Forms version, a template designer can be easily built and deployed royalty-free.
In our shipped samples, we demonstrate how to create templates by inserting the fields directly using the ApplicationField collection. This article describes how to create templates using the adapter fields. Additionally, it shows how to preview the template with the real data coming from a database.
This approach follows the same logic of creating a template like our shipped 'closed source' TX Template Designer:
- Open a database
- Select a table
- Insert fields
I will explain the sample in detail.
- First, click on Open Database... and browse for an XML database file. A sample file comes with this project. If the XML database could be loaded properly, the contained tables are listed in the first combobox.
- Select one of the listed tables. All column names will be added to the items of the second combobox.
- The column names are used as field names of the inserted merge fields. If an item is selected, click Add field to insert the merge field into the document.
- The loaded database is used to get the possible fields that can be used in the template. Additionally, the contained data rows can be used to preview the merged document. Click on Preview to enable the preview functionality.
Using the arrow buttons, you can navigate through the data rows of the current table to preview all rows. Feel free to use this nice approach as your basis for your own template designer.
Download the project and sample database file here (Visual Studio 2008 and at least a TX Text Control .NET for Windows Forms 15.0 trial version is required):
tx_template_designer_sample.zip
If you would like to discuss this approach or further possibilities, feel free to post a comment or contact me directly.
Related Posts
TX Text Control for Blazor: Mail Merge Integration Tutorial
This tutorial shows how to integrate the TX Text Control MailMerge component into a Blazor application using the TX Text Control .NET Server.
Mail Merge: Skipping Records During the Merge Process in .NET C#
This article shows how to skip records during the merge process in .NET C# using the MailMerge class of the Text Control Reporting engine.
Mail Merge MS Word DOCX Documents and Convert to PDF in .NET C#
This article shows how to merge data into MS Word DOCX documents and convert them to PDF using TX Text Control .NET Server.
Merging Self-Calculating Business Objects with TX Text Control MailMerge in C#
This article shows how to merge self-calculating business objects with TX Text Control MailMerge in C#. The sample shows how to merge a list of products with a total sum.
ASP.NETDigital SignatureDocument Viewer
Use Case: Create, Deploy and Process Insurance Claim Forms
Digital forms processing with electronic signatures offers several benefits that streamline and enhance administrative tasks. This article outlines a typical use case of an insurance claim form…