Skip to main content
A newer version of this page is available. .

How to: Resize Inline Picture

To change the size of the inline picture, get the collection of inline pictures using the SubDocument.Images property and change the scaling factor of the selected image using the DocumentImage.ScaleX and DocumentImage.ScaleY properties. You can also specify the image size directly using the DocumentImage.Size property.

The following example examines all images in the document. If the width of an image exceeds 50 millimeters, the image is scaled proportionally to half its size.

Document document = server.Document;
document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
ReadOnlyDocumentImageCollection images = document.Images;
// If the width of an image exceeds 50 millimeters, 
// the image is scaled proportionally to half its size.
for (int i = 0; i < images.Count; i++)
{
    if (images[i].Size.Width > DevExpress.Office.Utils.Units.MillimetersToDocumentsF(50))
    {
        images[i].ScaleX /= 2;
        images[i].ScaleY /= 2;
    }
}