Resize Image in a Word Document

[ ]

The DocumentBuilder provides several overloads of the InsertImage method that allow you to insert an inline or floating image. For example, the InsertImage method is used to insert an image from a file or URL into a document.

Using Shape class you can create or modify shapes in a Microsoft Word document.

The following code example shows how to resize an image:

Document doc = new Document();

// Create New Document.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Image Before Resize");
//insert image from disk
Shape shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg");

// Write text in document.
builder.Write("ReSize image ");
shape = builder.InsertImage(@"../../data/aspose_Words-for-net.jpg");

// Chaging image size. ConvertUtil Provides helper functions to convert between various measurement units. like Converts inches to points.
shape.Width = ConvertUtil.InchToPoint(0.5);
shape.Height = ConvertUtil.InchToPoint(0.5);

// Save document on file location.

See also: