
An instance of the ImageCollection class contains all images in a Text Control document or part of the document represented through objects of the type Image. An instance of this class can be obtained with the TextControl.Images, HeaderFooter.Images or TextFrame.Images property. The ImageCollection class implements the IEnumerable and the ICollection interfaces.
[C#]
public sealed class ImageCollection: ICollection, IEnumerable
[Visual Basic]
Public NotInheritable Class ImageCollection
Implements ICollection
Implements IEnumerable
| Property | Description | |
| Count | Gets the number of elements contained in the collection. | |
| ExportFilters | Gets all available filters for exporting images. | |
| ImportFilters | Gets all available filters for importing images. |
| Method | Description | |
| Add | Inserts a new image in a Text Control document. | |
| Clear | Removes all images from a Text Control document. | |
| CopyTo | Copies the elements of the collection to an array, starting at a particular index. | |
| GetEnumerator | Returns an enumerator that can be used to iterate through the collection. | |
| GetItem | Gets a particular image from the collection. | |
| Remove | Removes an image from a Text Control document. |
The following example iterates all images and sets the Image.SaveMode to SaveAsFileReference, so that all images will be exported the next time the document is saved. The images, will be saved in a subfolder called "'document name'_Images" of the location where the document has been saved to. The additional properties can be used to set the image's quality, format and maximum resolution.
[C#]
foreach (TXTextControl.Image myImage in textControl1.Images)
{
myImage.SaveMode = TXTextControl.ImageSaveMode.SaveAsFileReference;
myImage.ExportCompressionQuality = 100; //Export with maximum quality
myImage.ExportFilterIndex = 4; //Export as PNG format
myImage.ExportMaxResolution = 96; //Export with 96 DPI max
}
[Visual Basic]
For Each MyImage As TXTextControl.Image In TextControl1.Images
MyImage.SaveMode = TXTextControl.ImageSaveMode.SaveAsFileReference
MyImage.ExportCompressionQuality = 100 'Export with maximum quality
MyImage.ExportFilterIndex = 3 'Export as PNG
MyImage.ExportMaxResolution = 96 'Export with 96 DPI max
Next