Creating invoices is certainly one of the most typical applications for TX Text Control. MS Word compatibility,
and WYSIWYG template creation are just a few of the wide-ranging advantages over pure reporting tools.
This tutorial shows how to create professional invoices using TX Text Control. You will learn how to create the template using TX Text Control Words and how to use the MailMerge component to create the final invoice.
let's take a look at the data structure for invoices. Typically,
invoice data come from different database tables. The sender is coming
from a different table than the addressee. Invoice items are typically
loaded from an article database. The following tables are usually
required to create an invoice.
Creating the template
For this tutorial, we prepared a ready-to-use invoice template you can use, modify or redesign for your purposes. Refer to the documentation to learn how to use TX Text Control Words to create a template from scratch.
template consists of different parts with dynamic fields, repeating
blocks and special fields such as a field to display the current date.
merge fields from the listed data tables are used and have been added
to the above template. The green areas are repeating blocks that will be
merged with a list of invoice items and taxes.
Preparing the data
invoicing modules of ERP systems, the complete invoice is stored in
database tables. The resulting PDF or the printout is a specific view of
this invoice. The pure invoice data is used for further processing
inside the ERP system. This data gathering process is always different
and depends on the used databases and the .NET data layer (e.g.
In our sample, we are using an already merged DataSet in
form of an XML file that could have been generated as a database view
for real-live scenarios as well.
Merging the document as easy as 1-2-3
All you need to do is to connect a TextControl with the MailMerge component in order to load the template:
TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings();
ls.ApplicationFieldFormat = TXTextControl.ApplicationFieldFormat.MSWord;
mailMerge1.TextComponent = textControl1;
textControl1.Load("invoice.docx", TXTextControl.StreamType.WordprocessingML, ls);
The following code lines are required to merge the document:
DataSet ds = new DataSet();
Text Control is looking for the appropriate merge fields in the data
automatically in order to merge the fields. The repeating blocks are
recognized and merged with the associated DataTables.
How to use the sample?
Download the Visual Studio 2010 project
Download and open the project in Visual Studio 2010. At least, a TX Text Control .NET for Windows Forms trial version is required.
Start the application
The template is loaded automatically. You can see different text fields that are not merged yet.
Choose Create from the Invoice menu to start the merge process
data is merged into the text fields. Pay attention to the invoice items
that are part of a repeating block. These item lines are repeated based
on the number of invoice items passed in the data.
you can see, creating invoices using TX Text Control is a very easy
task and has advantages over pure reporting tools. You can easily change
your templates in a true WYSIWYG editor or reuse MS Word documents to
create your templates.
TX Text Control
was originally released in 1991, since then more than 50,000 copies have been sold. Starting off as a single, small DLL, TX Text Control
has made its way through 16-bit DLL and VBX versions to today‘s
Enterprise edition with its .NET and ActiveX components. The recent
addition to the family, TX Text Control .NET Server
, offers all of TX Text Control
advanced word processing functionality in an easy-to-use server-side
.NET component. Customers benefit from these years of experience, large
user base, and at the same time, appreciate developing with a mature,
North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)
Phone: +49 (0)421 42 70 67 10
Phone: +886 2-2797-8508