Free Support Forum -

Problem resize a pdf image

I have some problem using aspose.pdf. I want to insert a image in a pdf. I want that this image will have max width of 700. When i use the method “img1.setImageWidth(700)” it don’t do anything. All methods that modified image size don’t work. The only one that resize the image is the method “setImageScale” but i don’t want to use it. Even the method “getImageWidth” return always 0.

There is my code:

Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();

aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
final float maxMis=700;

obviously even if i delete the if and i set always the image Width to 700 it don’t works. The image don’t change width.

Can you help me?

Hi Fabio,

Thanks for using our products.

Please note that setImageWidth method in Image class has been deprecated and in order to set image width, please try using img1.getImageInfo().setFixWidth(…) method. In case you still face the same issue, please share the source image file so that we can test the scenario at our end. We are sorry for this inconvenience.