DocumentBuilderInsertImage Method (Image, Double, Double)
Inserts an inline image from a .NET Image object into the document and scales it to the specified size.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.10
Syntax
public Shape InsertImage(
	Image image,
	double width,
	double height
)

Parameters

image
Type: System.DrawingImage
The image to insert into the document.
width
Type: SystemDouble
The width of the image in points. Can be a negative or zero value to request 100% scale.
height
Type: SystemDouble
The height of the image in points. Can be a negative or zero value to request 100% scale.

Return Value

Type: Shape
The image node that was just inserted.
Remarks

You can change the image size, location, positioning method and other settings using the Shape object returned by this method.

Examples
Shows different solutions of how to import an image into a document from Image class.
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Image image = Image.FromFile(ImageDir + "Aspose.Words.gif");

builder.Writeln("\nInserted image from Image class: ");
builder.InsertImage(image);

builder.Writeln("\nInserted image from Image class with a custom size: ");
builder.InsertImage(image, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));

builder.Writeln("\nInserted image from Image class using relative positions: ");
builder.InsertImage(image, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
    100, 200, 100, WrapType.Square);

doc.Save(ArtifactsDir + "InsertImageFromImageClass.docx");
Examples
Shows different solutions of how to import an image into a document from Image class (.NetStandard 2.0).
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

using (SKBitmap bitmap = SKBitmap.Decode(ImageDir + "Aspose.Words.gif"))
{
    builder.Writeln("\nInserted image from Image class: ");
    builder.InsertImage(bitmap);

    builder.Writeln("\nInserted image from Image class with a custom size: ");
    builder.InsertImage(bitmap, ConvertUtil.PixelToPoint(250), ConvertUtil.PixelToPoint(144));

    builder.Writeln("\nInserted image from Image class using relative positions: ");
    builder.InsertImage(bitmap, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
        100, 200, 100, WrapType.Square);
}

doc.Save(ArtifactsDir + "InsertImageFromImageClass.NetStandard2.docx");
See Also