Free Support Forum - aspose.com

Crop image to 2x8.5 inch size

Hi Aspose Team,

We have a requirement where we need to crop image to 2x8.5 inch size if image is bigger than this size and show in word document and then into PDF document after conversion of word to pdf.

I saw Shape's ImageData has CropTop, CropBottom, CropLeft and CropRight properties whose values can be in range -1 to 1 i.e., fractional values.

Can you please share an example by using which I can show cropped image of size (2 x 8.5 inch)?

I'm using Aspose.Words V13.3.0.0.

Thanks,

Chandra

Hi Chandra,


Thanks for your inquiry. If I understand you correctly, you mean to resize the images. You can use the following code to resize images:

DocumentBuilder builder = new DocumentBuilder();

// By default, the image is inserted at 100% scale.

Shape shape = builder.InsertImage(@"C:\Temp\Aspose.Words.png");

// To change the shape size.

shape.Width = ConvertUtil.InchToPoint(2);

shape.Height = ConvertUtil.InchToPoint(8.5);

builder.Document.Save(@"C:\Temp\out.docx");


I hope, this helps.

PS: The CropBottom, CropLeft, CropRight and CropTop properties are used for the removal of the outer parts of an image

Best regards,