Supported File Formats
TX Text Control reads and writes the document formats itself, without Microsoft Word or Adobe Acrobat on the machine, so a WPF application opens a DOCX file, lets the user edit it and saves it as PDF with one load and one save. The table below lists every format with the enumeration value your code passes, followed by the Open and Save As dialog boxes of the WPF editor and what applies to PDF, Excel worksheets, images and Markdown.
Formats and StreamType Values
The Load and Save methods of WPF.TextControl and ServerTextControl take the format as a value of one of three enumerations, depending on where the data is:
- StreamType for a file path or a
FileStream - BinaryStreamType for a byte array
- StringStreamType for a string
A dash means that the enumeration has no value for the format.
| Format | Load | Save | StreamType | BinaryStreamType | StringStreamType |
|---|---|---|---|---|---|
| DOCX (Office Open XML) | Yes | Yes | WordprocessingML | WordprocessingML | — |
| DOC (Microsoft Word) | Yes | Yes | MSWord | MSWord | — |
| RTF | Yes | Yes | RichTextFormat | — | RichTextFormat |
| HTML | Yes | Yes | HTMLFormat | — | HTMLFormat |
| Yes | Yes | AdobePDF | AdobePDF | — | |
| PDF/A | No | Yes | AdobePDFA | AdobePDFA | — |
| XLSX (Office Open XML spreadsheet) | Yes | No | SpreadsheetML | SpreadsheetML | — |
| XML | Yes | Yes | XMLFormat | — | XMLFormat |
| CSS | No | Yes | CascadingStylesheet | — | CascadingStylesheet |
| Plain text, Unicode | Yes | Yes | PlainText | — | PlainText |
| Plain text, Windows ANSI | Yes | Yes | PlainAnsiText | — | — |
| TX Text Control format, Unicode | Yes | Yes | InternalUnicodeFormat | InternalUnicodeFormat | — |
| TX Text Control format, ANSI | Yes | Yes | InternalFormat | InternalFormat | — |
- Save only. PDF/A and CSS can only be saved. A CSS file contains the formatting styles of a document.
- Complete documents.
AdobePDFandAdobePDFAalways save the whole document, never a part of it. - Load only. XLSX is imported as a table, and the result is saved in one of the document formats. See Excel Worksheets.
- Paragraph ends. In both plain text formats, the control characters 13 and 10 end a paragraph.
- The internal format is the format of TX Text Control itself, which moves a document between
ServerTextControland the editor without a conversion.
The edition decides which formats you can use: the Standard edition reads and writes RTF and HTML, and File Formats by Edition lists what the Professional and Enterprise editions add.
The Open and Save As Dialog Boxes
Called without a path, a stream or data, Load and Save of WPF.TextControl open the Open and Save As dialog boxes, with a file type filter for each format you pass. Open and Save With the Built-In Dialog Boxes shows how to choose the filters, add the password and style sheet options and read the result. The overloads with a path, a stream, a byte array or a string load and save without asking the user.
TX Text Control creates and imports PDF documents with its own filters.
Export, PDF/A and PDF/UA
- PDF.
AdobePDFsaves a document as PDF, which can carry form fields, digital signatures, passwords and embedded files. See PDF Processing and Digital Signatures. - PDF/A. PDF/A is the ISO standard for archiving documents.
AdobePDFAwrites PDF/A-3a since version 34.0, a level that also allows embedded files, such as the XML data of an electronic invoice. See PDF/A and Attachments. - Tagged PDF for accessibility. Since version 34.0, every PDF document contains a logical structure that tags headings, paragraphs, tables, text frames and footnotes for assistive technologies such as screen readers. See Create an Accessible PDF (PDF/UA).
Version 34.0 in What's New describes the tagged output, and the blog article PDF/UA vs. PDF/A-3a: Which Format Should You Use for Your Business Application? compares the two standards.
PDF Import
AdobePDF also loads a PDF document, so that it can be edited or converted. TX Text Control rebuilds the text flow of the pages, and LoadSettings.PDFImportSettings chooses whether the result is lines of text, paragraphs or text frames close to the original appearance. PDF Import and Its Limitations explains each setting and what an imported PDF looks like.
Excel Worksheets (XLSX)
SpreadsheetML loads one worksheet of an XLSX file as a table. Which one is loaded is set in the LoadSettings:
- LoadSettings.GetDocumentPartNames returns the names of all worksheets of a file.
- LoadSettings.DocumentPartName selects a worksheet by name. When it is
null, the default, the first worksheet is loaded; when it is an empty string, a dialog box lists the worksheets and the user chooses one.
using System.Windows;
using TXTextControl;
private void worksheetButton_Click(object sender, RoutedEventArgs e)
{
// List the worksheets and load the first one
string[] sheets = LoadSettings.GetDocumentPartNames("report.xlsx", StreamType.SpreadsheetML);
LoadSettings loadSettings = new LoadSettings
{
DocumentPartName = sheets[0]
};
textControl1.Load("report.xlsx", StreamType.SpreadsheetML, loadSettings);
}
Tables in a document support Excel compatible formulas, which calculate a cell from other cells of the table. See Tables and Table Formulas. The formulas of a loaded worksheet become table formulas; Formula Functions lists the Excel functions Text Control names as supported.
Images
Documents contain images in BMP, TIF, WMF, PNG, JPG, GIF, EMF and SVG format, and Page.GetImage renders a whole page as an image. Image Formats lists the filter index of each format and how images are converted when a document is saved.
Markdown
Markdown has no StreamType value. The separate package TXTextControl.Markdown.Core on nuget.org imports and exports it with the extension methods LoadMarkdown and SaveMarkdown of the TXTextControl.Markdown namespace. Text Control names WPF among the targets of its import, besides ServerTextControl and Windows Forms. It handles headings, paragraphs, horizontal rules, blockquotes, lists, images, links and tables. The blog article Introducing TXTextControl.Markdown.Core: Import and Export Markdown in TX Text Control introduces it.