# Document Processing

> Process documents in Windows Forms code with TextControl and ServerTextControl: load, save, tables, headers, fields, forms, track changes, XML and printing.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Document Processing
- **1832 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/llms-full.txt

---

Most of what a user does with a document in the editor, your code does too: create and load documents, insert and format text, build tables, place images, add headers, fields and form fields, review changes, print and convert. Windows Forms developers who have finished the first tutorials find each of these tasks here in code, with the details from the object model to error handling.

### How Document Processing Works

Two classes hold a document, and both have the same programming interface for its content:

|  | `TextControl` | `ServerTextControl` |
|---|---|---|
| What it is | The editor control on your form | A component without a user interface |
| Shows the document | Yes | No |
| Used for | The document the user works on | Documents your code builds, converts, merges or prints |
| Thread | The UI thread of the form | Any thread, one instance per thread |

The examples of this section are button handlers in *Form1.cs* that work on a `TextControl` named `textControl1`, and use a `ServerTextControl` where the user doesn't need to see the document. The code that builds a document works with either class. Two rules apply everywhere:

- **Collections belong to the text part with the input focus.** In the `TextControl`, collections such as `Tables`, `TextFields` and `Comments` contain the elements of the main text, a text frame or a header or footer, depending on where the input position is. `TextParts` reaches all of them.
- **Positions count from 0 or from 1.** The input position and selections start at 0, the `Start` properties of paragraphs, fields and other elements at 1.

[Document Object Model](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/object-model/llms-full.txt) explains both in detail.

### Find the Right Page

| If you want to | Read |
|---|---|
| Understand how a document is organized in code | [Document Object Model](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/object-model/llms-full.txt) |
| Start a document, set its page format, combine documents | [Creating Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/creating/llms-full.txt) |
| Load DOCX, RTF, HTML or PDF files, byte arrays and streams | [Loading Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/loading/llms-full.txt) |
| Save a document or convert a folder to PDF | [Saving and Converting Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/saving-converting/llms-full.txt) |
| Find, replace and format text, use styles and lists | [Text, Paragraphs, and Stylesheets](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/text-paragraphs/llms-full.txt) |
| Fill tables from data and calculate with formulas | [Tables and Calculations](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/tables/llms-full.txt) |
| Place images, text frames and shapes | [Images, Text Frames, and Shapes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/images-shapes/llms-full.txt) |
| Insert charts and barcodes | [Charts and Barcodes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/charts-barcodes/llms-full.txt) |
| Add sections, landscape pages, headers, footers and page numbers | [Sections, Pages, Headers, and Footers](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/sections-headers/llms-full.txt) |
| Insert fields, links and bookmarks or mark ranges of text | [Fields and Subtext Parts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/fields/llms-full.txt) |
| Build fillable forms with validation | [Forms and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms-full.txt) |
| Track changes, add comments, accept and reject | [Comments and Tracked Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/comments-changes/llms-full.txt) |
| Edit XML files with a DTD and a stylesheet | [XML Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/xml/llms-full.txt) |
| Print in code, in the background or in batches | [Printing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/printing/llms-full.txt) |
| Process documents in the background without blocking the form | [Using ServerTextControl in Desktop Applications](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/servertextcontrol/llms-full.txt) |
| Catch and report errors | [Exceptions and Error Handling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/exceptions/llms-full.txt) |
| Write the rules that validate, enable and fill form fields | [Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/conditional-instructions/llms-full.txt) |
| Create content controls and read Word form fields | [Content Controls and Word Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/content-controls/llms-full.txt) |

### Where to Start

1. If you haven't yet, follow the tutorials of [Document Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-processing/llms-full.txt) in Getting Started: they create, save and print a first document.
2. Read [Document Object Model](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/object-model/llms-full.txt), which every other page builds on.
3. Read [Loading Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/loading/llms-full.txt) and [Saving and Converting Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/saving-converting/llms-full.txt), and [Using ServerTextControl in Desktop Applications](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/servertextcontrol/llms-full.txt) if your application processes documents the user doesn't see.
4. Continue with the page of the element you need, and add [Exceptions and Error Handling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/exceptions/llms-full.txt) before your application goes to users.

Filling templates with data is the subject of [Mail Merge and Reporting](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/llms-full.txt), and PDF options such as PDF/A and passwords are covered in [PDF Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/llms-full.txt). What users do with the same elements in the editor is described in [Document Editor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/llms-full.txt).

### Pages in This Section

- [Document Object Model](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/object-model/llms-full.txt): the parts of a document, text parts, positions and units.
- [Creating Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/creating/llms-full.txt): new documents, page format, combining documents and properties.
- [Loading Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/loading/llms-full.txt): load, append and insert with `LoadSettings`.
- [Saving and Converting Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/saving-converting/llms-full.txt): formats, parts of documents and `SaveSettings`.
- [Text, Paragraphs, and Stylesheets](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/text-paragraphs/llms-full.txt): selections, formatting, styles and lists.
- [Tables and Calculations](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/tables/llms-full.txt): tables from data, cell formatting and formulas.
- [Images, Text Frames, and Shapes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/images-shapes/llms-full.txt): frames inline, anchored or fixed on a page.
- [Charts and Barcodes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/charts-barcodes/llms-full.txt): charts and barcodes in documents.
- [Sections, Pages, Headers, and Footers](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/sections-headers/llms-full.txt): page layout, page numbers and the pages of a document.
- [Fields and Subtext Parts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/fields/llms-full.txt): text fields, links, bookmarks, Word fields and subtext parts.
- [Forms and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms-full.txt): form fields, protection and validation rules.
- [Comments and Tracked Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/comments-changes/llms-full.txt): tracking, comments and the final version.
- [XML Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/xml/llms-full.txt): XML files with DTD and CSS.
- [Printing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/printing/llms-full.txt): `PrintDocument`, batch printing and the formatting printer.
- [Using ServerTextControl in Desktop Applications](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/servertextcontrol/llms-full.txt): background work and moving documents to the editor.
- [Exceptions and Error Handling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/exceptions/llms-full.txt): the exceptions of TX Text Control and where to catch them.
- [Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/conditional-instructions/llms-full.txt): conditions, instructions and a complete booking form with rules.
- [Content Controls and Word Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/content-controls/llms-full.txt): the field adapters for content controls, legacy form fields and NEXT fields.

---

## In This Section

- [Charts and Barcodes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/charts-barcodes/llms-full.txt): Insert QR codes and Code 128 barcodes with TXBarcodeControl and BarcodeFrame, update them, and add charts bound to a DataTable in Windows Forms documents.
- [Comments and Tracked Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/comments-changes/llms-full.txt): Process comments and tracked changes in Windows Forms: comment on found text, accept one reviewer's changes, strip all markup and compare two versions.
- [Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/conditional-instructions/llms-full.txt): Set up conditional instructions for a Windows Forms TextControl in the dialog box or in C#: date, text and regex conditions, else values and radio buttons.
- [Content Controls and Word Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/content-controls/llms-full.txt): Create MS Word content controls and read legacy form fields in Windows Forms with ApplicationFieldFormat, ContentControlFieldAdapter, FormText and NextField.
- [Creating Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/creating/llms-full.txt): Create documents in a Windows Forms app: reset the editor, set page size and margins, insert Selection objects, append files, set properties and turn off undo.
- [Exceptions and Error Handling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/exceptions/llms-full.txt): Handle FilterException, LicenseLevelException and other TX Text Control exceptions in Windows Forms: return values, loading, Task.Run and ThreadException.
- [Fields and Subtext Parts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/fields/llms-full.txt): List the MS Word fields and links of every header, footer and text frame with TextParts in Windows Forms, read field codes and mark ranges with SubTextPart.
- [Forms and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms-full.txt): Process fillable forms in Windows Forms code: form field types, protection, value events, conditional instructions, reading values and flattening forms.
- [Images, Text Frames, and Shapes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/images-shapes/llms-full.txt): Place images, text frames and drawings inline, anchored or fixed in a Windows Forms document, add a watermark and render shapes as SVG with TXDrawingCore.
- [Loading Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/loading/llms-full.txt): Load, append and insert DOCX, RTF, HTML and PDF in a Windows Forms TextControl, control the import with LoadSettings, read metadata and handle FilterException.
- [Document Object Model](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/object-model/llms-full.txt): How TextControl and ServerTextControl organize a document: text parts, IFormattedText, frames, sections, the input focus rule, positions and twips.
- [Printing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/printing/llms-full.txt): Print from Windows Forms code with a PrintDocument: page ranges, copies, several files in one job, background printing, MailMerge.Print and FormattingPrinter.
- [Saving and Converting Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/saving-converting/llms-full.txt): Convert a folder to PDF with ServerTextControl, save selections and paragraphs, write HTML with CSS, shrink PDF images and omit comments with SaveSettings.
- [Sections, Pages, Headers, and Footers](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/sections-headers/llms-full.txt): Give sections their own headers, set page columns and borders, remove section breaks and render pages as images, SVG or TIFF in a Windows Forms TextControl.
- [Using ServerTextControl in Desktop Applications](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/servertextcontrol/llms-full.txt): Use ServerTextControl beside the Windows Forms editor: create and dispose it, pass documents as byte arrays, merge letters and license it in a class library.
- [Tables and Calculations](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/tables/llms-full.txt): Fill Windows Forms tables from data in code with TableCellFormat borders, header rows and column widths, nest tables and read or remove a document's tables.
- [Text, Paragraphs, and Stylesheets](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/text-paragraphs/llms-full.txt): Select, find and format text and paragraphs of a Windows Forms document in code, and read the paragraphs with their styles, lines and list numbers.
- [XML Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/xml/llms-full.txt): Load XML files with DTD and CSS into a Windows Forms TextControl, handle XmlInvalid, edit elements with GetXmlElements and the ButtonBar, and save XML and CSS.

---

## Nearby

- **Previous:** [Events](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/events/llms-full.txt)
- **Next:** [Document Object Model](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/object-model/llms-full.txt)
