Hi All,
I am using iText 5.4.0 -
I am not well-versed with iText and I am developing a report in it. I am
using a PdfPTable with 1 row. All the sections in the report are drawn
using this PdfPTable. In one of the sections of the report, i have to
display a header text and an image below it. The images generated are
dynamic. It could be just one image or even more than 10 images. The header
and the Image must always be displayed together.
Client is not convinced with the working of table.setHeaderRows(1);
So i used another PdfPTable(inner table) with 1 row and 2 cells, one for
the header and one for the image, inside the outer table PdfPTable(outer).
I am scaling an image based on a user requirement by using
*
*
*image.scaleToFit(imageWidthPx, imageHeightPx);*
*
*
*Now i am facing a problem with the image inside the innerTable. The image
is getting resized itself according the space left in the document which
should not happen.*
Is there any way to achieve this????
*Sample code:*
* {*
*//Main Outer table *
table = new PdfPTable(3);
table.setWidths(columnWidth);
table.setHeaderRows(1);
table.setWidthPercentage(100);
* //<Few Report Sections get generated here> *
*//Zooming the image as per user requirement*
if (imageWidthMm < 89 && imageHeightMm < 60) {
if (hashdata.get("ZOOMPER") != null &&
!(hashdata.get("ZOOMPER") +
"").equalsIgnoreCase("null") &&
!(hashdata.get("ZOOMPER") +
"").equalsIgnoreCase("")) {
imageHeightMm =
imageHeightMm *
((Float.parseFloat(hashdata.get("ZOOMPER") +
"") /
100));
imageWidthMm =
imageWidthMm *
((Float.parseFloat(hashdata.get("ZOOMPER") +
"") /
100));
}
imageHeightPx = imageHeightMm * 3.9370f;
imageWidthPx = imageWidthMm * 3.9370f;
image.scaleToFit(imageWidthPx, imageHeightPx);
}
else if ((imageWidthMm >= 89 && imageWidthMm < 119) &&
(imageHeightMm >= 51 && imageHeightMm < 60)) {
imageHeightPx = imageHeightMm * 3.9370f;
imageWidthPx = imageWidthMm * 3.9370f;
image.scaleToFit(imageWidthPx, imageHeightPx);
}
* //Image zooming ends here*
PdfPTable innerLabelTable = new PdfPTable(1);
innerLabelTable.setWidthPercentage(100);
PdfPCell innerLabelCell = new PdfPCell();
innerLabelCell.setVerticalAlignment(Paragraph.ALIGN_LEFT);
innerLabelCell.addElement(para);
innerLabelCell.setBorder(PdfPCell.NO_BORDER);
innerLabelCell.setPadding(1);
innerLabelTable.addCell(innerLabelCell);
innerLabelCell = new PdfPCell();
innerLabelCell.setVerticalAlignment(Paragraph.ALIGN_LEFT);
innerLabelCell.addElement(labelImage);
innerLabelCell.setBorder(PdfPCell.NO_BORDER);
innerLabelCell.setPadding(1);
innerLabelCell.setPaddingTop(3f);
innerLabelTable.addCell(innerLabelCell);
cell = new PdfPCell();
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.setVerticalAlignment(Element.ALIGN_LEFT);
* *cell.addElement(innerLabelTable)*; //Adding the inner
table to the outer table's cell*
cell.setBorder(PdfPCell.NO_BORDER);
cell.setPadding(3);
table.addCell(cell);
* }*
*
*
I have even tried *table.setKeepRowsTogether(true)*. Doesnt work well.
Report looks empty as it behaves like a *newPage() *when it cannot fit the
contents of the table in a single page.
Is there any way to achieve this????
Thanks a lot,
Harsha
*
*
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
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