I am not sure why it is not working the way you want it and don t want to
spend the time to investigate why. But, possible workarounds could be
Instead of using cell.setImage(); I would try new PdfPCell(image); and I
remember a flag to scale the image to fit the cell, so would try that as
well.
If nothing, you may scale the image to the desired fixed height before
placing in the cell using image.scale...
Good luck
Nurettin
On Sun, Oct 31, 2010 at 6:14 PM, Carmen Grantham
<[email protected]>wrote:
> Hi all,
>
> I'm in the process of upgrading to iText 2.1.7 but the setFixedHeight
> method of PdfCell doesn't work like it did in iText 1.4.6.
>
> The following is an example of code that I used in 2.1.7 (for 1.4.6
> change getScaledHeight() to scaledHeight()) that illustrates that it
> displays the image a lot larger than it did in 1.4.6. The code has
> been written this way so an image can be centred on the page.
>
> Document document = .......;
> PdfPTable table = new PdfPTable(1);
> Image image = Image.getInstance("image.jpg");
>
> PdfPCell cell = new PdfPCell();
> cell.setHorizontalAlignment(Element.ALIGN_CENTER);
> cell.setFixedHeight(image.getScaledHeight());
> cell.setImage(image);
> table.addCell(cell);
>
> document.add(table);
>
> document.add(new Paragraph("table height is " + table.getTotalHeight()));
>
>
> For an image that is 144 pixels high the table height output is 418.4
> in iText 2.1.7, but in iText 1.4.6 it is 144.0.
>
> Any ideas why this has changed and how I can change my code so that
> the image is created at the same size as iText 1.4.6?
>
> thanks,
> Carmen
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America
> contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
> marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>
--
Nurettin DAG
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php