Free Support Forum - aspose.com

SetImageSize - Bug or documentation error?

Hi Aspose Team,



i’m currently working with Aspose.Pdf.Kit to insert text and image
stamps into existing pdf documents. Works like a charm but a little
problem with the method SetImageSize. The documentation says, first parameter is the width, second parameter the height of the image. But i think it’s the opposite way.

For example i have an image width 100px width and 100px height. If i want to resize the image to 100px width and 50px (or percent, units, whatever you are using internally) height, the following code should work.


Dim MyStamp As New Aspose.Pdf.Kit.Stamp()

MyStamp.BindImage( “X:\folder\image.gif” )

MyStamp.Opacity = 0.5

MyStamp.SetImageSize( 100, 50 )



Dim PdfStamper As New Aspose.Pdf.Kit.PdfFileStamp( …, … )

PdfStamper.AddStamp( MyStamp )

PdfStamper.Close()



But the inserted image has now 50px width and 100px height. It doesn’t matter whether the pdf document is in portrait or landscape mode.

If you use the following code:


MyStamp.SetImageSize( 50, 100 )

the image has 100px width and 50px height.

Hi,

I have checked this and believe that this is an error in the documentation. I will discuss this with the developers to confirm this. Thank you for pointing it out.

Thanks.

Hi,

in the most scenarios, a method contains width and height parameters, the first parameter sets the width, second parameter the height. For an example take a look at: http://msdn2.microsoft.com/en-us/library/byca5y1f.aspx or http://msdn2.microsoft.com/en-us/library/9wcdy991.aspx

So the documentation should be correct :slight_smile:

Hi,

You are right. We will fix this problem in the new version.