Reputation: 1
Image image1 = Image.getInstance(sign);
image1.scaleAbsolute(150, 40);
//image1.scaleToFit(750, 50);
//image1.scalePercent(40f);
//image1.setScaleToFitLineWhenOverflow(true);
image1.setScaleToFitLineWhenOverflow(false);
cell18 = new PdfPCell(image1);
cell18.setPadding(padding);
cell18.setColspan(1);
cell18.setHorizontalAlignment(Element.ALIGN_CENTER);
cell18.setVerticalAlignment(Element.ALIGN_BOTTOM);
cell18.setBorderWidthLeft(borderWidthZero);
cell18.setBorderWidthRight(borderWidth);
cell18.setBorderWidthTop(borderWidthZero);
cell18.setBorderWidthBottom(borderWidthZero);
table.addCell(cell18);
table.completeRow();
How to fit an image to a particular cell if image size is grater than the particular cell? can any one please guide me?
Upvotes: 0
Views: 203
Reputation: 4871
PdfPCell has a constructor with an option to fit the image to the cell:
cell18 = new PdfPCell(image1, true);
Upvotes: 2