TX Text Control .NET for Windows Forms

Supported File Formats

Topic

A document in TX Text Control .NET for Windows Forms is loaded in one format and saved in the same or another one, so a conversion from DOCX to PDF takes one load and one save. Users do the same through the built-in Open and Save As dialog boxes. The formats are listed below with the enumeration values your code passes, followed by what applies to PDF, Excel spreadsheets, images and Markdown.

Formats and StreamType Values

The Load and Save methods of TextControl and ServerTextControl need the format of the data, given as a value of one of three enumerations:

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

FormatLoadSaveStreamTypeBinaryStreamTypeStringStreamType
DOCX (Microsoft Word, Office Open XML)YesYesWordprocessingMLWordprocessingML—
DOC (Microsoft Word binary format)YesYesMSWordMSWord—
RTF (Rich Text Format)YesYesRichTextFormat—RichTextFormat
HTMLYesYesHTMLFormat—HTMLFormat
PDFYesYesAdobePDFAdobePDF—
PDF/ANoYesAdobePDFAAdobePDFA—
XLSX (Microsoft Excel, Office Open XML)YesNoSpreadsheetMLSpreadsheetML—
XMLYesYesXMLFormat—XMLFormat
CSS (Cascading Style Sheet)NoYesCascadingStylesheet—CascadingStylesheet
Plain text, UnicodeYesYesPlainText—PlainText
Plain text, Windows ANSIYesYesPlainAnsiText——
TX Text Control format, UnicodeYesYesInternalUnicodeFormatInternalUnicodeFormat—
TX Text Control format, ANSIYesYesInternalFormatInternalFormat—
  • PDF/A and CSS are save-only formats. A CSS file holds the styles of a document, for example to format an XML document.
  • PDF and PDF/A are saved as complete documents. With AdobePDF and AdobePDFA, you cannot save only a part of a document.
  • XLSX is an import format. A worksheet is loaded as a table, and you save the result in a document format. See Excel Spreadsheets below.
  • Plain text marks the end of a paragraph with the control characters 13 and 10 (carriage return and line feed).

Which formats you can use also depends on the edition; File Formats by Edition lists them.

Open and Save As Dialog Boxes

In an application with a user interface, TextControl shows the standard file dialogs for you: Load and Save without a file name open an Open or Save As dialog box that offers the formats you pass. Loading and Saving Documents shows how to set the filters and the options of the dialogs, and Load and Save Documents in Getting Started builds the commands step by step.

PDF

TX Text Control creates and imports PDF documents with its own filters. Adobe Acrobat is not needed.

PDF Export and PDF/A

AdobePDF saves a document as PDF. The same document can carry form fields, digital signatures, passwords and embedded files, as described in PDF Processing and Digital Signatures.

PDF/A (ISO 19005) is the standard for the long-term archiving of documents. AdobePDFA saves a document as PDF/A, and since version 34.0, TX Text Control writes PDF/A-3a. PDF/A-3 allows files to be embedded in the document, such as the XML data of an electronic invoice. See PDF/A and Attachments.

Accessible PDF (PDF/UA)

Since version 34.0, a PDF document contains a logical structure in addition to its visible content, so that assistive technologies such as screen readers can follow it, and a document can comply with PDF/A-3a and PDF/UA at the same time. Create an Accessible PDF (PDF/UA) describes the structure and the alternative texts.

PDF Import

AdobePDF also loads a PDF document, so that it can be edited or saved in another format. A PDF file describes how its pages look, not the order of its text, so TX Text Control rebuilds the text flow, and LoadSettings.PDFImportSettings decides whether the result is plain lines, paragraphs or text frames that reproduce the original. Choose How the Document Is Rebuilt explains the settings and what to expect from an imported PDF.

Excel Spreadsheets (XLSX)

SpreadsheetML loads a worksheet of a Microsoft Excel XLSX file as a table. An XLSX file can contain several worksheets:

using TXTextControl;

// 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);

The tables of a document support Excel compatible formulas, which calculate their results from other cells of the same table. See Tables and Table Formulas.

Excel Functions in Loaded Worksheets

Text Control lists 55 Excel functions as supported in the formulas of a loaded worksheet: 47 mathematical and trigonometric functions from ABS to TANH, among them ROUND, SUM and SUMIF, the statistical functions AVERAGE, AREAS, MAX, MAXA, MIN and MINA, and the lookup and reference functions ADDRESS and ROW. Formula Functions lists all 55 and shows how to check at runtime whether SUMIF and AREAS, which the list of table formula functions doesn't contain, are available.

Images

Documents contain images in the formats BMP, TIF, WMF, PNG, JPG, GIF, EMF and SVG, and an image is saved in its original format unless you select another one. Images lists the import and export filters and the image formats each document format keeps.

Markdown

Markdown is not part of the StreamType enumeration. It is loaded and saved with the separate NuGet package TXTextControl.Markdown.Core from nuget.org, which adds the extension methods LoadMarkdown and SaveMarkdown in the TXTextControl.Markdown namespace. It supports headings, paragraphs, horizontal rules, blockquotes, lists, images, links and tables, and Text Control names Windows Forms applications among its uses. The blog article Introducing TXTextControl.Markdown.Core introduces the package.