scaleToFit() scales the image so that it fits in those dimensions 
maintaining the original aspect ratio. One of the dimensions will be one ot 
the scaleToFit arguments and the other will depend on the image aspect 
ratio.

Paulo

----- Original Message ----- 
From: "Thomas Jeziorny" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, May 30, 2007 9:26 PM
Subject: [iText-questions] Am I using scaleToFit correctly?


> Hello,
>
> I'm working on application that creates pdf documents that contain some
> client specific information along with a logo that our clients upload to
> our database in pdf format.
>
> I'm retieving the logo as a byte array ( from a BLOB)  that I then use to
> create an Image object.  Since the logos will vary, I'm using scaleToFit
> and setAbsolutePosition to place the logo on the page.
>
>>From reading the list archives and "IText in Action", my understanding is
> scaleToFit should stuff my image into the rectangle specified in the
> method parameters e.g scaleToFit(100, 400) should put my image in a 100 x
> 400 rectangle no matter what size the image is. Is this correct? Because
> what's happening now is that the rectangle seems to vary in size
> dependending on the image I use. I've put borders around the rectangle in
> order to see it better and it get's bigger or smaller depending on the
> image. I would have thought that the rectangle size should remain constant
> with Itext doing it's best to scale the image to fit -- making it either
> bigger or smaller to fill the specified space.
>
> I'm not sure if I'm misunderstanding what scale to fit does or if I've
> simply missed something. Any help would be greatly appreciated.
>
> Here's my code:
>
> PdfReader logoreader = new
> PdfReader(orsWhiteLbl.getBlob("CLIENT_LOGO").getBinaryStream());
> Image Logo = Image.getInstance(writer.getImportedPage(logoreader, 1));
> Logo.setBorder(Image.BOX);
> Logo.setBorderColor(java.awt.Color.red);
> Logo.setBorderWidth(1);
> Logo.scaleToFit(50, 400);
> Logo.setAbsolutePosition(10 + piX, 754 + piY);
> document.add(Logo);
>
> Regards,
>
> Tom Jeziorny


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to