【问题标题】:Issue with Column Width in IText 7 TablesIText 7 表中的列宽问题
【发布时间】:2018-03-20 15:08:06
【问题描述】:

我有如下固定列宽创建的下表,

 Table headerTable = new Table(new float[]{5,5,5});
 headerTable.setWidthPercent(100);

 headerTable.addCell(new Cell().add(new Paragraph("Student Name : Michel John(xxxx-xxx-xxx-xxx)")).setFontSize(10).setTextAlignment(TextAlignment.LEFT));
 headerTable.addCell(new Cell().add(new Paragraph("Admission Date : 2012-05-01")).setFontSize(10).setTextAlignment(TextAlignment.CENTER));
 headerTable.addCell(new Cell().add(new Paragraph("Current Standard : Eigth Standard - 'B' Section")).setFontSize(10).setTextAlignment(TextAlignment.RIGHT));

但是当我在我的 PDF 文件中看到输出格式时,列宽不均匀。

我在那个代码 sn-p 中遗漏了什么吗?

【问题讨论】:

    标签: itext itext7


    【解决方案1】:

    要固定列宽,我们可以在 iText7 中使用setFixedLayout()。它对我有用

        Table content = new Table(UnitValue.createPercentArray(new float[]{3,5,10}));
        content.setWidth(UnitValue.createPercentValue(100));
        content.setFixedLayout();
    

    【讨论】:

      【解决方案2】:

      请升级到最新版本的iText - 7.1.x 行 - 并使用下面的代码创建一个列宽均匀的表格:

      Table headerTable = new Table(UnitValue.createPercentArray(new float[]{5,5,5}));
      headerTable.setWidth(UnitValue.createPercentValue(100));
      

      【讨论】:

      • 这对我不起作用,有什么建议吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多