繁体   English   中英

IText 中的表格未添加正确的单元格

[英]Table In IText not adding correct Cells

我正在 Itext 中创建一个文档,并将其分解为 4 个主单元格,其中嵌套有表格。 我正在创建我的文档的最后一个单元格,除了每行中的第一个单元格之外什么都没有。

这是我正在调用的函数,它返回一个我添加到主文档中的单元格。

public PdfPCell getPSBioCell() {

    PdfPCell spaceCell = new PdfPCell(new Phrase(""));
    spaceCell.setColspan(1); // space
    spaceCell.setBorder(0);
    PdfPTable table = new PdfPTable(4);
    PdfPCell main = new PdfPCell();
    noBorder(main);//
    main.setPadding(0);//


    PdfPCell dist = new PdfPCell(new Phrase(_rangerDistrict, nf));
     PdfPCell district = new PdfPCell(new Phrase(this.sale.getRangerDistrict(), nf));
    PdfPCell saleD = new PdfPCell(new Phrase(_saleDate, nf));
    PdfPCell saleDate = new PdfPCell(new Phrase(this.formatDateString(sale.getSaleDate()), nf));
    PdfPCell awardD = new PdfPCell(new Phrase(_awardDate, nf));
    PdfPCell awardDate = new PdfPCell(new Phrase(this.formatDateString(sale.getAwardDate()), nf));
    PdfPCell termD = new PdfPCell(new Phrase(_termDate, nf));
    PdfPCell termDate = new PdfPCell(new Phrase(this.formatDateString(sale.getTerminationDate()), nf));
    PdfPCell avg = new PdfPCell(new Phrase(_avgDbh , nf));
    PdfPCell avgDbh = new PdfPCell(new Phrase(this.formatNumberString(String.valueOf(sale.getAveDiam())), nf));
    PdfPCell cruis = new PdfPCell(new Phrase(_cruiser, nf));
    PdfPCell cruiser = new PdfPCell(new Phrase(sale.getCruiser(), nf));
    noBorder(dist, district, saleD, saleDate);
    noBorder(awardD, awardDate, termD, termDate, avg);
    noBorder(avgDbh, cruis, cruiser);
    //
    table.addCell(dist);
    table.addCell(district);
    table.addCell(spaceCell);
    table.addCell(spaceCell);
    //
    table.addCell(saleD);
    table.addCell(saleDate);
    table.addCell(spaceCell);
    table.addCell(spaceCell);
    //
    table.addCell(awardD);
    table.addCell(awardDate);
    table.addCell(spaceCell);
    table.addCell(spaceCell);
    //
    table.addCell(termD);
    table.addCell(termDate);
    table.addCell(spaceCell);
    table.addCell(spaceCell);
    //
    table.addCell(avg);
    table.addCell(avgDbh);
    table.addCell(spaceCell);
    table.addCell(spaceCell);
    //
    table.addCell(cruis);
    table.addCell(cruiser);
    table.addCell(spaceCell);
    table.addCell(spaceCell);


    table.setWidthPercentage(100);
    main.addElement(table);
    return main;
}

这里的问题是在我的noBorder(PdfPcell)函数中,我正在执行cell.setBorder(0)但我也在执行cell.noWrap(true)所以将边框设置为0并将 noWrap 设置为true我看不到其他单元格被推离完成的 Pdf 页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM