Embedding Images in Various Formats
Documents containing BMP or WMF images grow in size when exported to Word or RTF formats because those formats use uncompressed data. TX Text Control .NET for Windows Forms reduces file sizes by embedding images as compressed JPG or PNG via the ExportFilterIndex property.

We are frequently asked why the filesize of documents containing images (BMP and WMF) grows when they are exported to Microsoft Word or RTF formats.
The answer is quite simple:
Images might be exported as a BMP or WMF files, which are typically built from uncompressed data.
Reducing the filesize of documents containing images is equally simple:
TX Text Control .NET for Windows Forms supports image export to external files, using compressed formats, such as JPG or PNG. Developers often are not aware that the image format can be also specified, if the images are embedded in the document itself.
The SaveMode property of the Image class specifies whether the image should be exported or embedded in the document.
The ExportFilterIndex, on the other hand, specifies the format of the image. Possible formats are: BMP, WMF, PNG or JPG.
In the following VB.NET sample, the resulting document size clearly demonstrates the effect of setting an appropriate image format:
BMP -> 151 KB WMF -> 53 KB PNG -> 56 KB JPG -> 13 KB
The sample shows how to change every image format in a document. The ComboBox receives all image formats from the Images.ExportFilters property.
For Each image As TXTextControl.Image In TextControl1.Images
image.ExportFilterIndex = ComboBox1.SelectedIndex + 1
image.SaveMode = TXTextControl.ImageSaveMode.SaveAsData
Next
Dim fileFormatIndex As String = ComboBox1.SelectedIndex + 1
TextControl1.Save("test_" + fileFormatIndex + ".rtf", TXTextControl.
StreamType.RichTextFormat)Related Posts
Inserting Images from Memory
TX Text Control .NET for Windows Forms supports loading images from files in various formats, but some workflows require inserting images that exist only in memory. This sample application…
Create a Table of Contents in Windows Forms using C#
This article explains how to create a table of contents in Windows Forms using the ribbon or programmatically. Creating a table of contents is required to organize large documents.
Two Ways to Restart Numbered Lists in TX Text Control
In TX Text Control, numbered lists are continued by default and need to be reset when required. There is more than one way if you want to restart numbered lists in a document. In this article, two…
Paste Special: The Easy Way to Implement
TX Text Control version 15.0 introduced a ClipboardFormat parameter on the Paste method, enabling native Paste Special functionality. The GetClipboardFormats method returns all available clipboard…
How to Remove All Section Breaks in a Document?
TX Text Control 15.0 adds per-section page column support alongside existing section breaks. To remove all section breaks programmatically, iterate through SectionCollection using…
