# ServerTextControl

> Use ServerTextControl in a WPF application to build, merge and convert documents without a window, then load the result into WPF.TextControl as a byte array.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Overview > Components > ServerTextControl
- **1545 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/components/servertextcontrol/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/components/servertextcontrol/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/components/servertextcontrol/llms-full.txt

---

A WPF application often has documents to build, merge or convert that the user never needs to watch being made. `ServerTextControl` is the document engine of TX Text Control without an element on screen: it runs the same programming interface as the editor in memory, and when a result should be seen, the `WPF.TextControl` in your window loads it. Read on for when a WPF application uses it, the pattern every use follows and how documents travel between the two classes.

### What ServerTextControl Is

[ServerTextControl](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/llms-full.txt) is the class `TXTextControl.ServerTextControl` in the assembly *TXTextControl.Server.dll*, which the NuGet package `TXTextControl.TextControl.WPF.SDK` includes. It is derived from `System.ComponentModel.Component`, not from a WPF control, so it has no template, no visual tree and no place in XAML. You create it in code whenever you need it.

It shares the document interface of [WPF.TextControl](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/components/textcontrol/llms-full.txt): the `Load`, `Save` and `Append` methods, the `Selection`, and the collections of tables, images, fields, sections and other elements. The classes of these elements are in the `TXTextControl` namespace and are the same for both, so a method that builds a document can take either object.

The client license of TX Text Control .NET for WPF covers `ServerTextControl` and `MailMerge` in desktop applications. Text Control opened both classes to the Windows Forms and WPF products with version X8, without a separate server or runtime license.

### When a WPF Application Uses It

- **Preparing a document before it is shown.** Code assembles or merges a document in a `ServerTextControl` and hands the finished result to the editor, so the user sees no intermediate steps.
- **Work that has nothing to do with the open document.** Converting files to PDF, creating a series of letters or exporting a report runs apart from the document in the editor.
- **Mail merge in the background.** A [MailMerge](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/components/mailmerge/llms-full.txt) whose `TextComponent` is a `ServerTextControl` creates documents while the editor shows something else.

Without a user interface, a `ServerTextControl` keeps no undo history and renders nothing for the screen. Text Control names better performance, support for several threads and a smaller memory footprint as the advantages over a visible control. [Performance](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/llms-full.txt) covers background work and the WPF dispatcher.

### How You Work With It

Each use follows the same three steps:

1. **Create and initialize.** Create an instance and call [Create](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/create-method/llms-full.txt) before any other member. Put the instance into a `using` statement, which disposes it and releases its resources when the work is done.
2. **Load or build the document.** [Load](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/load-method/llms-full.txt) replaces the contents with a document, [Append](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/append-method/llms-full.txt) adds one at the end, and [Selection](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/selection-property/llms-full.txt) inserts and formats text.
3. **Save the result.** [Save](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/save-method/llms-full.txt) writes the whole document to a file, a stream, a byte array or a string.

The format is a [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) for files and streams, a [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) for byte arrays and a [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) for strings. [Supported File Formats](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/file-formats/llms-full.txt) lists the values.

#### Hand a Document to the Editor

`WPF.TextControl` has the same byte array overloads of `Load` and `Save`, so a document built in a `ServerTextControl` moves into the editor as a byte array in the TX Text Control format, without a conversion. [Show a Document Built in Code](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-processing/servertextcontrol/#show-a-document-built-in-code) shows the code, and [Create a Document Programmatically](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-processing/create/llms-full.txt) builds a first document step by step.

### Key Members

| Member | Purpose |
|---|---|
| [Create](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/create-method/llms-full.txt) | Initializes the resources of a new instance. It must be called first. |
| [Load](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/load-method/llms-full.txt), [Append](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/append-method/llms-full.txt) | Replace the contents with a document, or add one at the end. |
| [Save](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/save-method/llms-full.txt) | Saves the complete document in the format you pass. |
| [Text](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/text-property/llms-full.txt), [Selection](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/selection-property/llms-full.txt) | The text of the document, and the selection that inserts and formats text. |
| [Tables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/tables-property/llms-full.txt), [Images](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/images-property/llms-full.txt), [HeadersAndFooters](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/headersandfooters-property/llms-full.txt) | The tables, images, headers and footers. |
| [ApplicationFields](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/applicationfields-property/llms-full.txt), [FormFields](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/formfields-property/llms-full.txt) | Fields such as MS Word merge fields, and form fields. |
| [Comments](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/comments-property/llms-full.txt), [TrackedChanges](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/trackedchanges-property/llms-full.txt) | The comments and the tracked changes. |
| [Print](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/print-method/llms-full.txt) | Prints without showing the document, using a `System.Drawing.Printing.PrintDocument`. |
| [EntryAssembly](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/entryassembly-property/llms-full.txt) | A static property that names the assembly holding the license, for example when the class is used in a class library. |

The [ServerTextControl](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/servertextcontrol/llms-full.txt) reference lists all members.

### Next Steps

- [Create a Document Programmatically](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-processing/create/llms-full.txt) — a first document built in code.
- [Using ServerTextControl in Desktop Applications](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-processing/servertextcontrol/llms-full.txt) — background work and the editor in detail.
- [Document Processing](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-processing/llms-full.txt) — create, load, save and change documents in code.
- [MailMerge](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/components/mailmerge/llms-full.txt) — merge templates with data in a `ServerTextControl`.

---

## Nearby

- **Previous:** [MailMerge](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/components/mailmerge/llms-full.txt)
- **Next:** [Supported Platforms](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/overview/platforms/llms-full.txt)
