Document Processing
Not every document in a WPF application is typed by its user. Reports are assembled from data, files arrive in one format and must leave in another, and letters go to the printer without being opened. Three short tutorials handle these jobs with button handlers in the window of your first application, using ServerTextControl, the document engine without a user interface, next to the TextControl in XAML.
Choose a Tutorial
| Tutorial | You learn to | Main members |
|---|---|---|
| Create a Document Programmatically | Build a report with formatted text, a table, an image and a header, save it as DOCX and show it in the editor | ServerTextControl, Selection, Tables, Images, HeadersAndFooters |
| Save as DOCX and PDF | Export the editor's document and convert Word files in the background | Save, StreamType, ServerTextControl |
| Print a Document | Print with the print dialog and without one, print files with ServerTextControl and set the formatting printer | Print, PageRange, PrintDocument, FormattingPrinter |
Before You Start
- Complete Create Your First WPF Application. The tutorials add buttons to its window, next to the
TextControlnamedtextControl1. - If
ServerTextControlis new to you, read ServerTextControl in the Overview first. Every instance has to be initialized withCreatebefore use and disposed afterward. - DOCX, DOC and PDF need the Professional or Enterprise edition. See Editions and Feature Availability.
Each tutorial can be followed on its own. In the order of the table, they go from creating a document to saving it and printing it.
Where WPF Differs
ServerTextControl, Selection, SaveSettings and the other classes that build and save documents are shared with TX Text Control .NET for Windows Forms, and code that uses them looks the same in both. The differences are in the window around it:
- Buttons and handlers are declared in XAML, and a
Clickhandler receivesRoutedEventArgs. - Dialogs come from WPF:
Microsoft.Win32.OpenFileDialogfor files and the print dialog of WPF for printing. - Printing from the editor uses the print system of WPF, with a printer name, a
PageRangeand a copy count. Printing withServerTextControluses aPrintDocument, which a .NET WPF project gets from the NuGet package System.Drawing.Common.
After These Tutorials
- Mail Merge: fill templates with data instead of building each document in code.
- PDF Processing: PDF options, PDF forms and digital signatures.
- Document Processing: creating, loading, converting and printing documents in detail.