5
我创建了单独的单元格中的表格中的6个图像,即使我设置图像的高度和宽度在服务器端完全相同与ScaleToFit图像大小是不一样的在pdf页面上。itextsharp和图像大小
有无论如何获得所有的图像完全相同的大小?
PdfPTable table = new PdfPTable(3);
table.HorizontalAlignment = Element.ALIGN_CENTER;
table.WidthPercentage = 100;
table.TotalWidth = 698.5f;
table.LockedWidth = true;
table.SetWidths(new float [] {1,1,1});
iTextSharp.text.Image img1 = iTextSharp.text.Image.GetInstance("C:\\Users\\DaNet\\Downloads\\image.jpg");
img1.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
img1.ScaleToFit(120f, 155.25f);
iTextSharp.text.pdf.PdfPCell imgCell1 = new iTextSharp.text.pdf.PdfPCell(img1);
imgCell1.HorizontalAlignment = Element.ALIGN_CENTER;
imgCell1.BackgroundColor = new BaseColor(255, 255, 255);
imgCell1.Border = iTextSharp.text.Rectangle.NO_BORDER;
table.AddCell(imgCell1);
它看起来很喜欢图像是适当的大小,现在谢谢!现在我必须将它定位在细胞中,即使它是细胞的一个元素。最后,我认为这不是我想要做的最好的选择。 – DaNet
只需使用img1.ScaleAbsolute(120f,155.25f);图像完美贴合细胞。干杯克里斯! – DaNet
如果我想要我的图像35x35毫米,那么我该怎么办?如何计算它在毫米? –