DocumentBuilderInsertImage Method (String, Double, Double)
Inserts an inline image from a file or URL into the document and scales it to the specified size.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 20.1
public Shape InsertImage(
	string fileName,
	double width,
	double height


Type: SystemString
The file that contains the image.
Type: SystemDouble
The width of the image in points. Can be a negative or zero value to request 100% scale.
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.

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

Shows different solutions of how to import an image into a document from a string.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("\nInserted image from string: ");
builder.InsertImage(ImageDir + "Aspose.Words.gif");

builder.Writeln("\nInserted image from string with a custom size: ");
builder.InsertImage(ImageDir + "Aspose.Words.gif", ConvertUtil.PixelToPoint(250),

builder.Writeln("\nInserted image from string using relative positions: ");
builder.InsertImage(ImageDir + "Aspose.Words.gif", RelativeHorizontalPosition.Margin, 100, 
    RelativeVerticalPosition.Margin, 100, 200, 100, WrapType.Square);

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