Resize Image in a Word Document
Contents
[
Hide
]
See more details in the Working with Images documentation section.
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 Shapeclass 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");
// Changing 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.
builder.Document.Save("ImageReSize.doc");
The ConvertUtilclass provides helper functions to convert between various measurement units, like conversion inches to points.
See also: