Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
« »

Embedding images in various formats

Blogged by Björn Meyer on April 06, 2005 and tagged with Samples, Image, .NET.

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

The working VB.NET sample can be downloaded here.

« Prev:Adjusting table columns using inches
» Next:Field at Input Position

Comments

If you would like to comment on this blog entry, please post a comment.

Posted by Scott on Monday, April 11, 2005 at 22:25:35:

Are you going to support inline image data anytime soon?Here's an example: http://scott.connerly.net/sideload/inline.html
It works on Moz but not IE or TX Text Control right now.

Posted by Björn Meyer on Tuesday, April 12, 2005 at 15:07:04:

Very interesting question. I am going to discuss this with our developer team.

Posted by Scott on Friday, September 23, 2005 at 07:57:44:

Any thoughts yet on supporting this?I know the company that I work for (that already subscribes to TX) would have great use for it.I would restrain from identifying my company, as this is not an 'official' posting...

Posted by Björn Meyer on Friday, September 23, 2005 at 09:51:35:

I discussed this feature with our HTML filter specialists. We are going to consider that with special regard to the new trojans and viruses in JPG images. IMHO, this is a very sensitive way to include images in an HTML document.

Posted by Scott on Wednesday, September 28, 2005 at 18:41:06:

In case you wanted the RFC's on this protocol, here you go:
http://www.ietf.org/rfc/rfc2557.txt
http://www.faqs.org/rfcs/rfc2397.html
Thank you for considering including this.

Posted by Sabrina on Tuesday, January 22, 2008 at 15:07:19:

Question, maybe silly for youbut why in any place of the documentation of your control there is not a list of the ExportFilterIndex values and their meaning?
I've found a thread on an error and in that thread such as in this post it is indicated that the above property can be used to avoid problems.
Now I've found it can be set to 3 but what means 3 BMP?JPG?WMF?PNG?TIF?
In the documentation in the CHM and also in the online documentation the property is described but there is not a reference table.
This property as many others in your control is an integer, why not use an Enum???
Sorry but I'm a little bit frustrated because I'm not able to save and reload a document with images from your control and I have a demo tomorrow morning, if you can let know to the people who writes the documentation that the admissible values for the enumerated properties would be a helpful addin to the property definition it would be very kind.

Sabrina

Posted by Igal Foigel on Saturday, May 16, 2009 at 17:27:44:

Hey,

I've noticed Scott's question from Apr 2005 regarding inline image data for HTML format.

My company is in the process of finding a solution like TX Text Control offers and this feature -inline image data for HTML format-stands as a central requirement.

Is this feature included in the latest TX Text Control .NET for WinForms? If not - can we expect it in the near future?

Thanks,
Igal

Posted by Björn Meyer on Monday, May 18, 2009 at 09:21:48:

Hello

Quick note: TX Text Control 15.0 now supports embedded images in HTML in all versions.
External verification page for ISO 9000:2000 certificate
ISO 9001:2000
certified