Hi Guys,

I'm having an issue where a jpeg image placed into a cell appears slightly
distorted, for the most part it's the text that's in the image (it's a logo).
I've tried with and without using scaleToFit with the exact dimensions of the
logo and it's no good. If I scale it down then the image looks better (as the
pixels are compressed). If I copy the image from the pdf and paste into
photoshop it appears fine.

Photo is at 72dpi , 500x100 pixels (though I've tried different sizes, similar
reaction). When I view the pdf in acrobat pro the document shows as being at 72
dpi as well. I've tried hard coding the scaleToFit as well. If you want a copy
of the pdf and image, just let me know where to send it.

Here's my code, what the heck am I missing? I use acrobats ruler and the
dimensions are the same as what they should be.

I include normal photos throughout the report at they appear fine as the
original is so much larger and they are scaled down (and have no text).

Here's the code:

PdfPCell cell = new PdfPCell();
                
Image photo1 = Image.getInstance(logo.getAbsolutePath());                    
                                        
// set the scale info for the logo. since it might be smaller
// than our settings, we don't want to make it enlarged (distorted)

scaleWidth = 500f, scaleHeight = 150f;
                    
if(photo1.width() < 501f){
  scaleWidth = photo1.width();
}
                    
if(photo1.height() < 151f){
  scaleHeight = photo1.height();
}
                    
System.out.println("Logo Size: " + scaleWidth + ", " + scaleHeight);
                    
photo1.scaleToFit(scaleWidth, scaleHeight);
cell = new PdfPCell(photo1);
cell.setBorderWidth(0);




-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to