| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual Basic .NET |
| Version: | 1.0 |
| Released: | April 07, 2005 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with Visual Basic .NET |
| Download code: | tx_sample_dotnet_export.zip |

TX Text Control offers two possibilities to save images in documents: embedded or as external image files. Possible image formats are BMP, WMF, PNG and JPG. These image export filters are shipped with every version of TX Text Control.
Sometimes it is necessary to keep files small in order to save hard disk space or bandwidth, if the document is sent by email. In this case, it is often desirable to offer end users the option of converting images in the document to a compressed format such as JPG. This sample shows how to convert every image in the document to a specified format.
There are two important properties that can be used to specify the format and way the image is included in the document:
Image.ExportFilterIndexImage.SaveModeWe use the Images collection to iterate through all images in the document to specify the new image export format. Additionally, the SaveMode property determines whether the image should be embedded or exported.
For Each image As TXTextControl.Image In TextControl1.Images image.ExportFilterIndex = ComboBox1.SelectedIndex + 1 If RadioButton1.Checked = True Then image.SaveMode = TXTextControl.ImageSaveMode.SaveAsData Else image.SaveMode = TXTextControl.ImageSaveMode.SaveAsFileReference End If Next
In this sample, we used a ComboBox to select the image format. This list can be easily filled with the Images.ExportFilters property which returns all available filters. The following code fills this ComboBox with the appropriate content.
Dim imageFormats() As String imageFormats = TextControl1.Images.ExportFilters.Split("|") For i As Integer = 0 To 7 Step 2 ComboBox1.Items.Add(imageFormats(i)) Next ComboBox1.SelectedIndex = 0
As ever, we would be delighted to help you with this sample. Please contact the Support Department, if you have any questions about this sample. The sample requires Visual Studio 2003 and at least a TX Text Control .NET 11.0 trial version.