Free Support Forum -

Insert Image in PDF

We want to insert a series of images with different sizes in a PDF, so we can stretch them all to have the same size. So far, we are doing it with the AddImage method.

What's happening is that if the image size is smaller than the rectangle where we want to insert it, Aspose Kit PDF is adjusting the image proportionally. So, what we would like is it to strectch the size so it can adjust in the rectangle defined in AddImage.


//Instantiate PdfFileMendor object and pass input and output PDF file streams to its constructor

PdfFileMend mendor = new PdfFileMend(inPdfStream, outputStream);

//Call AddImage method and pass image, page number and (X,Y) axis information

mendor.AddImage(inImgStream, 1, 250, 250, 500, 500);

Hello Ruben,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Using ImageInfo object that is encapsulated in Image class, we can Get or set FixHeight & FixWidth. A float value that indicates the fixed height/width of the image. If this property is set, the image will be scaled to the fixed height/width.

For more information on adding images into Pdf, kindly visit Use Image from Local Disk.
For more information on
ImageInfo and list of all members of this type, see ImageInfo Members.

You can also use ImageScale property of Image class which is used to Get or set a float value that indicates the scale rate of the image when placed into pdf file.

Hi Ruben,

Thank you for considering Aspose.

You could treat the image as a Stamp and set the image size, and then use the method PdfFileStamp.AddStamp().

Please refer to