Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

TX Text Control

News and interesting articles about the word processing component TX Text Control.

Advantages of the TX Text Control API over MS Word Automation

If you ever used Microsoft Word Automation in one of your projects, you will know how complex the manipulation of a document can be. Word Automation is a technology that can be used to manipulate Word documents in .NET applications by using the client executable of MS Word.

Documents can be manipulated using a hard to use API called the Word Object Model. In case you are using the Office Open XML SDK to manipulate DOCX files, similar knowledge about the actual document is required in order to properly change or build a document.

In order to do simple tasks such as adding a paragraph to a document, the following code is required:

Word.Application wordApp = new Word.Application(); 
wordApp.Visible = true
Word.Document doc = wordApp.Documents.Add(); 
Word.Range range = doc.Content; 
Word.Paragraph paragraph = range.Paragraphs.Add(); 
paragraph.Range.Text = "Hello World!";

In comparison to those tree-based models, the TX Text Control API is much better structured, easy to learn and more understandable without any document format specific knowledge.

Referring to the above sample, this task can be easily achieved using the TX Text Control API:

TXTextControl.ServerTextControl doc = new TXTextControl.ServerTextControl(); 
doc.Selection.Text = "Hello World!";

You can see the difference quite easily: While you need extensive knowlegde about the document structure when using MS Word Automation, you simply use the Selection object in TX Text Control.

In TX Text Control, collections are available for all elements such as tables, images, pages, paragraphs or sections. Let's say you want to insert an image on every page without using headers and footers:

foreach (Page page in textControl1.GetPages()) 

    TXTextControl.Image img = new TXTextControl.Image(); 
    img.FileName = "tx_text_control_logo.png"
        new Point(100100), 

You can easily loop through the collection of pages in order to add a new image to each page. You don't need to use enumerators, but you have access to very easy-to-use collections.

In order to add text at a specific character location, the Selection object can be utilized. You simply create a new Selection object with a start index. In the next scenario, a new formatted text should be inserted at a specific character location:

TXTextControl.Selection sel = new Selection(); 
sel.Start = 5
sel.Bold = true
sel.Text = "New Text"
textControl1.Selection = sel;

There are other collections on top of this concept that can be used to get a specific start index for the Selection. Consider the following situation: You want to insert a new text at the beginning of page 5. The Page object returns the start index through the Start property which then can be used with the Start property of the Selection. The Selection.Start property is 0-based (input position) while the character positions are all 1-based - therefore, 1 must be subtracted from the return value. The following code inserts new text on page 5:

TXTextControl.Selection sel = new Selection(); 
sel.Start = textControl1.GetPages()[5].Start - 1
sel.Text = "New Text on Page 5"
textControl1.Selection = sel;

Conclusion: TX Text Control offers a very easy-to-learn API to create and manipulate documents in a very fast and efficient way. Powerful collections and objects can be used instead of complex tree-based object models.


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, reliable product.
North & South America: Phone: +1 704-370-0110 Phone: +1 877-462-4772 (toll free)
Europe: Phone: +49 (0)421 42 70 67 10
Asia Pacific: Phone: +886 2-2797-8508


Published Wednesday, February 13, 2013 6:39 AM by Christopher Krause

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS


No Comments

Leave a Comment

Enter the code you see below


This Blog