# Document Conversion

> Solve loading and saving problems in TX Text Control .NET for Windows Forms: FilterException reasons, wrong formats, protected PDFs, missing images and fields.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Troubleshooting > Document Conversion
- **2767 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/conversion/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/conversion/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/conversion/llms-full.txt

---

Loading a document into the `TextControl` or saving it can fail with a `FilterException`, or it succeeds and the result isn't what you expected. Both kinds of problem follow, starting with the exception and its reason. Text that looks different because a font is missing is covered on [Fonts and Document Layout](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/fonts/llms-full.txt), and a feature that your edition doesn't include on [Licensing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/licensing/llms-full.txt).

### Read the Reason of a FilterException

When a text filter can't convert a document to or from a format, [TextControl.Load](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/load-method/llms-full.txt) and [Save](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/save-method/llms-full.txt) throw a [FilterException](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/filterexception/llms-full.txt). Its message contains an error number in parentheses, and its [Reason](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/filterexception/reason-property/llms-full.txt) property names the cause as a value of [FilterException.FilterError](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/filterexception/filtererror-enumeration/llms-full.txt). The following code in *Form1.cs* loads a document into `textControl1` and shows both when loading fails:

```csharp
using System.Windows.Forms;
using TXTextControl;

private void openButton_Click(object sender, EventArgs e)
{
    try
    {
        textControl1.Load("contract.docx", StreamType.WordprocessingML);
    }
    catch (FilterException exception)
    {
        // The message contains the error number, Reason the cause
        MessageBox.Show($"{exception.Reason}: {exception.Message}");
    }
}
```

The reasons have these meanings:

| Reason | Meaning |
|---|---|
| `WrongFileType` | The file type is not supported through the filter. |
| `BadToken` | There is a logical error in the file. |
| `OutOfMemory` | Unable to allocate enough memory. |
| `CannotRead`, `CannotWrite`, `CannotOpen` | The file can't be read, written or opened. |
| `FileTooBig` | The input file is too big. |
| `Unsupported` | Unsupported format version. |
| `Internal` | Unspecified internal error. |
| `Obsolete` | The filter is obsolete. |
| `NotWellFormed` | The file contains not well-formed syntax. |
| `Encrypted` | The document cannot be imported because the used encryption scheme is not supported. |
| `NonEmbeddableFont` | The document cannot be saved, because it contains a non-embeddable font. See [Fonts and Document Layout](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/fonts/llms-full.txt). |
| `InvalidCertificate` | The specified certificate is invalid or has no private key. |
| `InvalidTimeServer` | The specified time server does not exist or retrieves invalid data. |
| `InvalidPassword` | The specified user-password is invalid. |

The error number gives more detail than the reason. Text Control's Error Navigator looks it up; the blog article [Text Control Error Navigator Launched](https://www.textcontrol.com/blog/2022/08/15/text-control-error-navigator-launched/) explains how to search it.

### The File Type Is Not Supported Through the Filter

Loading fails with a message such as:

```text
Text filter error: The file type is not supported through the filter.
(1-1D01)
```

The reason is `WrongFileType`: the data doesn't have the format that the format value of `Load` names, for example a string of plain text loaded as RTF.

1. Pass the value that matches the data: a value of [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) for a file, of [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) for a byte array and of [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) for a string.
2. `BinaryStreamType` has no value for HTML or RTF. Load these formats from a string or a file.
3. `StreamType.AdobePDFA` and `StreamType.CascadingStylesheet` are for saving only. To load a PDF document, use `StreamType.AdobePDF`.

[Load and Save Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/load-save/llms-full.txt) shows which value belongs to which format.

### A Password-Protected PDF Doesn't Load

Loading a PDF document throws a `FilterException` whose `Reason` is `InvalidPassword`.

The PDF document is protected with a user password, which has to be passed when it's loaded. The TX Words Ribbon sample handles this case: when loading fails with this reason, it asks for the password and loads the document again.

1. Ask the user for the password.
2. Load the document again with the password in [LoadSettings.UserPassword](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsavesettingsbase/userpassword-property/llms-full.txt).
3. Apply the permissions of the document to the editor, as [Respect the Permissions of a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/security/pdf-passwords/#respect-the-permissions-of-a-pdf) shows. With the correct [MasterPassword](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsavesettingsbase/masterpassword-property/llms-full.txt), no restrictions apply.

If the `Reason` is `Encrypted`, the document uses an encryption that TX Text Control can't import, such as 256-bit AES or certificates. [Encrypted PDF Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/import/#encrypted-pdf-documents) lists the algorithms it imports.

### A Loaded PDF Contains No Text

A PDF document loads without an error, but the editor shows no text, or the text can't be selected.

A PDF document describes what each character looks like and where it is, but not always which character it is. Most PDF documents contain a mapping to the characters, and without it no text can be extracted. A scanned page is an image and contains no text at all.

1. Check the text after loading, for example with [ServerTextControl.Text](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/servertextcontrol/text-property/llms-full.txt) when you convert without the editor, and skip or report documents without text.
2. Run scanned documents through OCR software before you import them.
3. To read text together with its position on the page, use [PDF.Contents.Lines](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-pdf/contents-lines/llms-full.txt), as [Text Extraction](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/text-extraction/llms-full.txt) describes.

### The TXTextControl Object Must Have Been Completely Loaded

A member of a `ServerTextControl` throws this message:

```text
The TXTextControl object must have been completely loaded to use this method.
```

The instance isn't initialized: [ServerTextControl.Create](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/servertextcontrol/create-method/llms-full.txt) wasn't called before the member, or it returned `false`. [Create Returns False](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/native-libraries/#create-returns-false) gives the causes and the fix.

### Images Are Missing After Loading

Where an image should be, the document shows a rectangle of the image's size with the file name of the image.

An image inserted from a file can be saved as a reference to the file, with its absolute path. When the document is loaded on a machine where this path doesn't exist, the image can't be found. [LoadSettings.LoadImages](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsettings/loadimages-property/llms-full.txt) set to `false` shows the same rectangles.

1. Set [LoadSettings.ImageSearchPath](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsettings/imagesearchpath-property/llms-full.txt) to the folder that holds the images. It replaces the absolute paths in the document. Relative paths are resolved with [DocumentBasePath](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsavesettingsbase/documentbasepath-property/llms-full.txt).
2. Make sure `LoadImages` isn't `false`.
3. To find the paths a template uses, read [Image.FileName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/image/filename-property/llms-full.txt) of its images.

### Word Fields Are Missing After Loading

A DOCX, DOC or RTF document from Microsoft Word loads, but its merge fields or other fields aren't in [TextControl.ApplicationFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/applicationfields-property/llms-full.txt), or its merge blocks aren't recognized.

By default, fields of other applications are not imported as application fields: [LoadSettings.ApplicationFieldFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsettings/applicationfieldformat-property/llms-full.txt) is `None`. Bookmarks that span several characters, which mark merge blocks in Word documents, become document targets unless you load them as subtext parts.

1. Set `ApplicationFieldFormat` to `MSWord` to import the fields of Word as application fields, or to `MSWordTXFormFields` to import its form fields as form fields of TX Text Control.
2. Set [LoadSettings.LoadSubTextParts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsettings/loadsubtextparts-property/llms-full.txt) to `true` to load bookmarks that span several characters as subtext parts. It applies to DOCX, DOC and RTF.
3. Pass the `LoadSettings` to `Load`.

[Mail Merge](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/mail-merge/llms-full.txt) covers fields and blocks that don't merge.

### The Converted Document Looks Different

A document converted to another format, such as DOCX to PDF, has other line breaks, page breaks or fonts than the original.

TX Text Control lays out a document with the fonts available on the machine and the text dimensions of the formatting printer. When a font of the document is missing, another one replaces it, and the layout changes.

1. Find out which fonts are replaced, as [Fonts and Document Layout](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/fonts/llms-full.txt) describes.
2. Check that the format you save to supports what the document contains. [Supported File Formats](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/file-formats/llms-full.txt) lists the formats and their features.
3. Check that your edition includes the format: the Express edition has no DOCX, DOC or PDF, and the Professional edition no PDF/A. See [Editions and Feature Availability](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/editions/llms-full.txt).

### Saving as PDF Fails in an Earlier Service Pack

Saving a document as PDF or PDF/A fails with a `FilterException` whose message contains an error number such as `01-1D09`, or the saved PDF lacks content, while other documents save without problems.

The PDF export of version 34.0 writes tagged PDF, and the service packs of 34.0 fixed several documents that it couldn't save. The Known Issues page of version 34.0 lists, among others, these fixes:

| Fixed in | Documents that failed or were saved incompletely |
|---|---|
| Service Pack 1 | Saving as PDF or PDF/A hung the `TextControl` or `ServerTextControl` |
| Service Pack 2 | Lists mixed with normal paragraphs, text frames, Unicode characters, table headers in PDF/A, invalid links in PDF/A, and check box form fields in PDF/A |
| Service Pack 4 | Lists mixed with paragraphs without list levels, lists and content in headers or footers, styles with a structure level above 6, and signature fields outside the first or last paragraph |
| Service Pack 5 | Images with a compression quality of 100, SVG images with embedded PNG images in signature fields, and the font of form fields |

1. Read the service pack your application runs with from [VersionInfo.ServicePack](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/versioninfo/servicepack-property/llms-full.txt), as [Service Packs](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/whats-new/service-packs/#check-the-installed-service-pack) shows.
2. Install the latest service pack, update `TXTextControl.TextControl.WinForms.SDK` to 34.0.5 and rebuild the application.
3. If the error remains, look up the error number as described in [Read the Reason of a FilterException](#read-the-reason-of-a-filterexception), and check the open issues on the [Known Issues](https://www.textcontrol.com/product/tx-text-control-dotnet-winforms/issue/3400/) page. An error `1-1D09` when loading some PDF documents is listed there as open.

### Related Pages

- [Load and Save Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/load-save/llms-full.txt): load and save documents in the editor.
- [Exceptions and Error Handling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/exceptions/llms-full.txt): the exceptions of TX Text Control in detail.
- [Supported File Formats](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/file-formats/llms-full.txt): what each format supports.

---

## Nearby

- **Previous:** [Printing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/printing/llms-full.txt)
- **Next:** [Mail Merge](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/mail-merge/llms-full.txt)
