TX Text Control .NET for WPF

Supported File Formats

Topic

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:

A dash means that the enumeration has no value for the format.

FormatLoadSaveStreamTypeBinaryStreamTypeStringStreamType
DOCX (Office Open XML)YesYesWordprocessingMLWordprocessingML—
DOC (Microsoft Word)YesYesMSWordMSWord—
RTFYesYesRichTextFormat—RichTextFormat
HTMLYesYesHTMLFormat—HTMLFormat
PDFYesYesAdobePDFAdobePDF—
PDF/ANoYesAdobePDFAAdobePDFA—
XLSX (Office Open XML spreadsheet)YesNoSpreadsheetMLSpreadsheetML—
XMLYesYesXMLFormat—XMLFormat
CSSNoYesCascadingStylesheet—CascadingStylesheet
Plain text, UnicodeYesYesPlainText—PlainText
Plain text, Windows ANSIYesYesPlainAnsiText——
TX Text Control format, UnicodeYesYesInternalUnicodeFormatInternalUnicodeFormat—
TX Text Control format, ANSIYesYesInternalFormatInternalFormat—
  • Save only. PDF/A and CSS can only be saved. A CSS file contains the formatting styles of a document.
  • Complete documents. AdobePDF and AdobePDFA always 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 ServerTextControl and 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.

PDF

TX Text Control creates and imports PDF documents with its own filters.

Export, PDF/A and PDF/UA

  • PDF. AdobePDF saves 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. AdobePDFA writes 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:

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.