Products Technologies Demo Docs Blog Support Company

Embedding Images in Various Formats

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…

Embedding Images in Various Formats

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)

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

Image.NETSample

Inserting Images from Memory

Recently, a new sample has been released in the source code library. TX Text Control offers various functions to insert images from physical files in many supported formats. Sometimes, however, it…


Windows FormsWPF.NET

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.


Windows FormsList.NET

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…


.NETSample

Paste Special: The Easy Way to Implement

In an older sample, I showed how to implement a paste special functionality by accessing the clipboard directly using .NET functionality. In version 15.0, we implemented this functionality…


.NETSampleSections

How to Remove All Section Breaks in a Document?

With version 14.0, we introduced document section breaks that allow you to have different page formats in the same document. Version 15.0 implements page columns that can be adjusted section-wise.…