TX Text Control .NET for WPF

Document Processing

Topic

After the first tutorials, a WPF application usually needs more than loading and saving: tables filled from data, headers with page numbers, fields, forms, tracked changes, printing and conversions that run while the window stays responsive. Each of these tasks is shown below in the code-behind of a window, together with the object model behind it, one page per element your application works with.

How Document Processing Works

A document lives either in the WPF TextControl that the user sees or in a ServerTextControl that has no user interface:

TXTextControl.WPF.TextControlTXTextControl.ServerTextControl
DeclaredIn XAML, as WPF:TextControlIn code, with new, Create and using
Shows the documentYesNo
ThreadThe UI thread of the windowAny thread, one instance per thread
Used forThe document the user editsDocuments your code builds, converts, merges or prints

Both share the classes that describe the content, such as Selection, Paragraph, Table, Section and TextField, so the same code builds a document in either. The examples of this section are handlers in MainWindow.xaml.cs for a TextControl named textControl1. Two rules hold throughout:

  • A collection belongs to the text part with the input focus. Tables, TextFields, Comments and similar collections of the TextControl contain the elements of the main text, a text frame or a header or footer, depending on where the cursor is. TextParts contains all parts.
  • Positions count from 0 or from 1. Selections and the input position start at 0; the Start of paragraphs, fields and other elements starts at 1.

Document Object Model describes both rules and the structure of a document.

Find the Right Page

TaskPage
Learn how the parts of a document are organizedDocument Object Model
Start a document, set its page format, combine documentsCreating Documents
Load files, byte arrays, strings and streamsLoading Documents
Save, convert to PDF and control the outputSaving and Converting Documents
Find, replace and format text; styles and listsText, Paragraphs, and Stylesheets
Build tables and formulasTables and Calculations
Add images, text frames and shapesImages, Text Frames, and Shapes
Add charts and barcodesCharts and Barcodes
Set up sections, headers, footers and page numbersSections, Pages, Headers, and Footers
Work with fields, links, bookmarks and subtext partsFields and Subtext Parts
Create forms and validate their valuesForms and Conditional Instructions
Record, review and remove comments and changesComments and Tracked Changes
Edit XML data with a DTD and CSSXML Processing
Print from code and in the backgroundPrinting
Keep the window responsive during long workUsing ServerTextControl in Desktop Applications
Catch errors and exceptionsExceptions and Error Handling
Validate form values with rules: operators, instruction types, radio button groupsConditional Instructions
Read Word form fields and create content controls with field adaptersContent Controls

Pages in This Section