表中的图像未正确对齐

时间:2015-11-17 06:25:00

标签: itext

我在我的android项目中使用iText库来创建PDF文件。我已经使用库成功创建了PDF。但是我面临着一个问题,即表格。我在第一列中有一个图像,该图像仅在第一行收缩和截止。其余的行按预期工作正常。请在下面找到附带的屏幕截图和源代码

for(int i = 0; i < deductiblesArray.length(); i++) {

            Bitmap bitmap = getBitmapFromAssets("images/count_bg.png", mContext);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
            Image imgBusinessLogo = null;
            int indentation = 0;
            try {
                imgBusinessLogo = Image.getInstance("images/count_bg.png");
                imgBusinessLogo.scaleToFit(50f, 50f);
            } catch (IOException e) {
                e.printStackTrace();
            }
            imgBusinessLogo.setAlignment(Image.MIDDLE);
            PdfPCell c1 = new PdfPCell(imgBusinessLogo, false);
            c1.setCellEvent(new WatermarkedCell("" + arrDeductiblesCountArray.getString(i)));
            //c1.setImage(imgBusinessLogo);
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            c1.setVerticalAlignment(Element.ALIGN_CENTER);
            c1.setRowspan(3);
            c1.setPaddingBottom(5);
            c1.setPaddingTop(5);
            //c1.setFixedHeight(100);
            c1.setBorder(0);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Name"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            c1.setBorder(0);
            c1.setPaddingBottom(5);
            c1.setPaddingTop(5);
            c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(c1);

Image is here

0 个答案:

没有答案