IdxRichEditDocumentImageCollection.Append(TGraphic) Method
Adds a new inline image to the end of a subdocument.
Declaration
function Append(AImage: TGraphic): IdxRichEditDocumentImage;
Parameters
Name | Type | Description |
---|---|---|
AImage | TGraphic | The source container that contains an image in any supported bitmap format. |
Returns
Type | Description |
---|---|
IdxRichEditDocumentImage | An inserted inline document image. Returns |
Remarks
Call the Append
function to add a new inline image to the end of the parent subdocument.
Code Example
The following code example allows users to select an image in any format and insert the image at the end of a document opened in a TdxRichEditControl:
uses
..., dxSVGImage; // This unit contains the TdxSVGImageCodec class declaration
//...
procedure TMyForm.cxButton1Click(Sender: TObject);
var
ADocument: IdxRichEditDocument;
AImageContainer: TdxSmartImage;
AFileName: string;
begin
ADocument := dxRichEditControl1.Document;
dxOpenPictureDialog1.Execute(Handle); // Invokes the "Open" dialog for image file selection
AFileName := dxOpenPictureDialog1.FileName;
if (AFileName = '') then Exit; // Exits the procedure if a user selects no image
AImageContainer := TdxSmartImage.Create; // Creates a Smart Image container
try
AImageContainer.LoadFromFile(AFileName);
if (AImageContainer.ImageCodec = TdxSVGImageCodec) then // If the container stores an SVG image
AImageContainer.ConvertToBitmap; // Rasterizes the vector image
ADocument.Images.Append(AImageContainer); // Creates a new inline image from the stored bitmap
finally
AImageContainer.Free; // Destroys the Smart Image container to prevent memory leaks
end;
end;
Limitations
An inline document image’s Office Image container does not support vector images to ensure compatibility with popular document formats. Ensure that the source image container (a TdxSmartImage or TdxSmartGlyph instance) does not contain an SVG image. Otherwise, an exception occurs.
Tip
You can call the image container’s ConvertToBitmap procedure to rasterize the stored image as demonstrated in the code example in the current help topic.