itextsharp - Image resizes when inserted in PdfCell -
i'm trying create pdf using itextsharp. have added 1 table conataining 2 columns 1 containing text , other image. want have constant image size
my image automatically resizes if text present in cell increases , image present in other cell has different sizes
(int = 0; < visitinfo.visitsitecomplience.count; ++i) { cellprop.colspan = 1; cellprop.pharse = visitinfo.visitsitecomplience[i].compliencedescription; cellprop.basecolor = null; table.addcell(addcelltotable(cellprop)); yesicon.scaleabsolute(35f, 35f); noicon.scaleabsolute(35f, 35f); if (visitinfo.visitsitecomplience[i].status == "1") { statuscell.addelement(new chunk(noicon, 0, 0)); } else { // statuscell.addelement(new chunk(noicon, 0, 0)); } statuscell.fixedheight = 10; //headerleftcell.border = pdfpcell.no_border; table.addcell(statuscell); }
2. changed code image size increases , occupies full cell
(int = 0; < visitinfo.visitsitecomplience.count; ++i) { cellprop.colspan = 1; cellprop.pharse = visitinfo.visitsitecomplience[i].compliencedescription; cellprop.basecolor = null; table.addcell(addcelltotable(cellprop)); yesicon.scaleabsolute(35f, 35f); noicon.scaleabsolute(35f, 35f); if (visitinfo.visitsitecomplience[i].status == "1") { statuscell.addelement(new chunk(noicon, 0, 0)); } else { // statuscell.addelement(new chunk(noicon, 0, 0)); } //headerleftcell.border = pdfpcell.no_border; table.addcell(statuscell); }
i think you're scaling image this: noicon.scaleabsolute(35f, 35f);
it puzzles me why you're wrapping image inside chunk
. can create pdfpcell
takes image
parameter bool
defines whether or not itext should scale image
. see page 109 of book itext in action (of i'm author) , take @ xmen example of chapter 4.
Comments
Post a Comment