# Different Ways to Create Documents using Text Control Products

> Text Control offers four document creation paths: building from scratch via the ServerTextControl API, merging pre-designed templates with MailMerge using IEnumerable or DataSet sources, editing in WYSIWYG rich text controls for Windows Forms and WPF, and generating via ReportingCloud.

- **Author:** Bjoern Meyer
- **Published:** 2017-10-17
- **Modified:** 2026-03-05
- **Description:** Text Control offers four document creation paths: building from scratch via the ServerTextControl API, merging pre-designed templates with MailMerge using IEnumerable or DataSet sources, editing in WYSIWYG rich text controls for Windows Forms and WPF, and generating via ReportingCloud.
- **5 min read** (809 words)
- **Tags:**
  - ASP.NET
  - Mail Merge
  - Reporting
  - ReportingCloud
  - Windows Forms
  - WPF
- **Web URL:** https://www.textcontrol.com/blog/2017/10/17/ways-to-create-documents-using-text-control-products/
- **LLMs URL:** https://www.textcontrol.com/blog/2017/10/17/ways-to-create-documents-using-text-control-products/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2017/10/17/ways-to-create-documents-using-text-control-products/llms-full.txt

---

Text Control products can be used to create documents programmatically from scratch, pre-designed templates can be used to populate merge fields using the TXTextControl.DocumentServer.MailMerge class and documents can be edited using true WYSIWYG rich text controls for [Windows Forms](https://www.textcontrol.com/product/tx-text-control-dotnet-winforms/), [WPF](https://www.textcontrol.com/product/tx-text-control-dotnet-wpf/) and [ASP.NET](https://www.textcontrol.com/product/tx-text-control-dotnet-server/).

### Creating Documents From Scratch

TX Text Control provides a powerful and complete API to create and manipulate documents programmatically. This API can be used in any .NET application such as Windows applications, Windows Service applications or web services.

The following code creates a new instance of a TXTextControl.ServerTextControl class which is the non-visual Text Control. The API is compatible to the visual controls such as the Windows Forms TXTextControl.TextControl class and the WPF TXTextControl.WPF.TextControl class.

The code inserts a paragraph, a table and exports the document as an Adobe PDF document:

```
using (ServerTextControl tx = new ServerTextControl())
{
    tx.Create();

    // create a new selection range
    Selection range = new Selection();
    range.Bold = true;
    range.FontSize = 400;
    range.Text = "This is a new paragraph\r\n";

    // insert the range to the document
    tx.Selection = range;

    // add a table
    tx.Tables.Add(5, 5, 10);

    foreach (TableCell cell in tx.Tables.GetItem(10).Cells)
    {
        cell.Text = cell.Row.ToString() + ", " + cell.Column.ToString();
    }
    
    // save the document as PDF
    tx.Save("test.pdf", StreamType.AdobePDF);
}
```

### Merging Templates Using MailMerge

After a template has been successfully designed in one of the visual rich text controls of TX Text Control or in MS Word, the reporting engine TXTextControl.DocumentServer.MailMerge class is merging data into the template. For each data row of the master table in the data source, a document is created. Merge fields are populated with column values and repeating blocks are merged with data rows of related child tables in the data source.

A data source can be any IEnumerable object (business objects), JSON objects, DataSet and DataTable objects. Text Control Reporting follows the concept of pre-shaped data where data queries are executed before data is passed to the merge process.

The following code creates an instance of the reporting engine *MailMerge* to merge the template that is loaded into a *ServerTextControl* with an *IEnumaerable* object. Finally, the document is exported as a PDF document:

```
// create a business object that is used
// as the data source
Invoice invoice = new Invoice() { Name = "Report" };

using (ServerTextControl tx = new ServerTextControl())
{
    tx.Create();

    LoadSettings ls = new LoadSettings() {
        ApplicationFieldFormat = ApplicationFieldFormat.MSWord
    };

    // load the created template
    tx.Load("template.docx", StreamType.WordprocessingML, ls);

    // create a new MailMerge engine
    using (MailMerge mailMerge = new MailMerge())
    {
        // connect to ServerTextControl
        mailMerge.TextComponent = tx;

        // merge the template that is loaded with
        // the business object
        mailMerge.MergeObject(invoice);                
    }

    // export the document as PDF
    tx.Save("test.pdf", StreamType.AdobePDF);
}
```

### Editing Documents Using MS Word-Compatible Editors

The TXTextControl.WPF.RibbonReportingTab class represents a ribbon tab to integrate mail merge and reporting functionality directly into your TX Text Control based application. Together with all other ribbon tabs known from typical word processors, creating MS Word compatible template designers and word processors is a very easy task.

Not being dependent on an additional third-party tool such as MS Word to create templates is a very important key aspect when implementing word processing functionality into business applications. The MS Word compatible editor has the look and feel of MS Word, but can be customized and adapted to user requirements. MS Word templates can be reused and edited in TX Text Control.

Templates can be stored in industry standard(ized) formats such as DOCX, DOC and RTF and are always compatible with other word processors such as MS Word.

The following screenshot shows the Windows Forms version of TX Text Control. The visual controls can be automated in the same way like the non-visual class *ServerTextControl* using the same, compatible API.

![Creating documents with TX Text Control](https://s1-www.textcontrol.com/assets/dist/blog/2017/10/17/a/assets/textcontrol.webp "Creating documents with TX Text Control")

### Creating Documents in the Cloud

The [ReportingCloud](https://www.textcontrol.com/product/reporting-cloud/) Web API can be used to merge MS Word compatible templates with JSON data from all clients such as .NET, .NET Core, Javascript, PHP, Node.JS, jQuery, Python, Android, Java, iOS and many more.

ReportingCloud provides a RESTful Web API to manage templates and to merge templates with hierarchical data from JSON strings.

The following code uses ReportingCloud and the ReportingCloud .NET Wrapper to merge data into a template:

```
ReportingCloud rc = new ReportingCloud(
  "username",
  "password",
  new Uri("https://api.reporting.cloud"));

// create dummy data
Invoice invoice = new Invoice();

// create a new MergeBody object
MergeBody body = new MergeBody();
body.MergeData = invoice;

// merge the document
List<byte[]> results = rc.MergeDocument(body, templateName, ReturnFormat.PDF);
```

### Conclusion

Text Control provides the most powerful tools and controls to integrate document creation processes into any kind of business applications.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [MailMerge: Conditional Table Cell Colors using Filter Instructions](https://www.textcontrol.com/blog/2019/06/06/mailmerge-conditional-table-cell-colors-using-filter-instructions/llms.txt)
- [MailMerge: Using Filters to Remove Unwanted Rows](https://www.textcontrol.com/blog/2019/06/04/mailmerge-using-filters-to-remove-unwanted-rows/llms.txt)
- [Creating Templates: Typical Invoice Elements](https://www.textcontrol.com/blog/2019/04/16/typical-invoice-elements/llms.txt)
- [TX Text Control 32.0 Has Been Released](https://www.textcontrol.com/blog/2023/09/13/tx-text-control-320-has-been-released/llms.txt)
- [An Ultimate Guide to Mail Merge with MS Word Documents in C#](https://www.textcontrol.com/blog/2023/06/07/an-ultimate-guide-to-mail-merge-with-ms-word-documents-in-csharp/llms.txt)
- [TX Text Control 31.0 and TX Spell .NET 10.0 Have Been Released](https://www.textcontrol.com/blog/2022/09/07/tx-text-control-31-released/llms.txt)
- [Mail Merge with MS Word Documents in C# - An Ultimate Guide](https://www.textcontrol.com/blog/2022/05/25/mail-merge-with-ms-word-documents-in-csharp-an-ultimate-guide/llms.txt)
- [Combining MailMerge and Table of Contents](https://www.textcontrol.com/blog/2022/03/22/combining-mailmerge-and-table-of-contents/llms.txt)
- [Merging Form Fields using the MailMerge Class](https://www.textcontrol.com/blog/2022/02/21/merging-form-fields-using-the-mailmerge-class/llms.txt)
- [MailMerge: Rendering Conditional Table Rows](https://www.textcontrol.com/blog/2022/02/17/mailmerge-rendering-conditional-table-rows/llms.txt)
- [TX Text Control 30.0 and TX Spell .NET 9.0 Have Been Released](https://www.textcontrol.com/blog/2021/11/29/tx-text-control-30-released/llms.txt)
- [TX Text Control X19 and TX Spell 8.0 Have Been Released](https://www.textcontrol.com/blog/2020/12/02/tx-text-control-x19-released/llms.txt)
- [TX Text Control X18 has been Released](https://www.textcontrol.com/blog/2020/03/16/tx-text-control-x18-released/llms.txt)
- [TX Text Control X17 has been Released](https://www.textcontrol.com/blog/2019/05/28/tx-text-control-x17-released/llms.txt)
- [Create and Modify Adobe PDF Documents within your .NET Application](https://www.textcontrol.com/blog/2019/05/27/create-and-modify-adobe-pdf-documents/llms.txt)
- [Text Control Roadmap 2019: High DPI Support, Forms, Node.js and Angular](https://www.textcontrol.com/blog/2019/03/12/text-control-roadmap-2019/llms.txt)
- [TX Text Control X16 and TX Barcode .NET 5.0 Released](https://www.textcontrol.com/blog/2018/11/14/tx-text-control-x16-and-tx-barcode-net-50-released/llms.txt)
- [Generate Word Documents from Templates in .NET](https://www.textcontrol.com/blog/2018/08/10/generate-word-documents-from-templates-in-net/llms.txt)
- [Overview: What is Text Control?](https://www.textcontrol.com/blog/2018/07/26/overview-what-is-text-control/llms.txt)
- [Sneak Peek X16: Filter and Sort MergeBlock Rows](https://www.textcontrol.com/blog/2018/04/26/sneak-peek-x16-filter-and-sort-mergeblock-rows/llms.txt)
- [X15: Merging Data into Chart Objects](https://www.textcontrol.com/blog/2018/01/05/merging-data-into-charts/llms.txt)
- [TX Text Control X15 and TX Spell .NET 7.0 Released](https://www.textcontrol.com/blog/2017/12/13/tx-text-control-x15-and-tx-spell-net-70-released/llms.txt)
- [Sneak Peek X15: MS Word Compatible Document Protection and Editable Regions](https://www.textcontrol.com/blog/2017/11/16/ms-word-compatible-editable-regions/llms.txt)
- [Using Custom Document Properties to Store Additional Document Information](https://www.textcontrol.com/blog/2017/02/09/using-custom-document-properties-to-store-additional-document-information/llms.txt)
- [X14 Preview: Build Your Own Template Designer with the New DataSourceManager Class](https://www.textcontrol.com/blog/2016/11/15/x14-preview-build-your-own-template-designer-with-the-new-datasourcemanager-class/llms.txt)
