Free Support Forum -

Change DPI of all pictures befor saving to *.doc or *.docx

Hi, I can ask if is possible change DPI or resolution of all images in document befor saving in *.doc or *.docx format. I use Aspose.Word.

Thanks a lot. Michal


Thanks for your request. Aspose.Words does not allow you to do this directly, but you can use the following workaround.
1. Get objects that contain images.
2. Convert these objects to Bitmap and change the resolution.
3. Save Bitmap to the original object.
Please see the code below.

string filename = @“in.doc”;

Document doc = new Document(filename);


foreach (ImageData item in doc.GetChildNodes(NodeType.DrawingML, true))


Bitmap image = (Bitmap)item.ToImage();

image.SetResolution(20, 20);




foreach (Shape item in doc.GetChildNodes(NodeType.Shape, true))


Bitmap image = (Bitmap)item.ImageData.ToImage();

image.SetResolution(20, 20);




Best regards,