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):
If you would like to discuss this approach or further possibilities, feel free to post a comment or contact me directly.