【问题标题】:How to create inner table with PDFBox 2 and Boxable?如何使用 PDFBox 2 和 Boxable 创建内表?
【发布时间】:2019-08-31 15:51:06
【问题描述】:

我正在使用 PDFBox v2 和 boxable,我需要生成一个内部有 2 行的单元格。

我试图像wiki 解释的那样,但在我的应用程序单元格内容中按字面意思打印。

生成内表的代码为:

activeRow.createCell(100f, "<table><tr><td> R1 </td></tr><tr><td> R2 </td></tr></table>");

出了什么问题?

谢谢!

【问题讨论】:

    标签: java pdfbox boxable


    【解决方案1】:

    我回答我自己的问题。

    问题是致电createCell()。创建内表的正确方法是createTableCell()

    【讨论】:

      【解决方案2】:
           float margin = 80;
          // starting y position is whole page height subtracted by top and bottom margin
          float yStartNewPage = page.getMediaBox().getHeight() - (2 * margin);
          // we want table across whole page width (subtracted by left and right margin ofcourse)
          float tableWidth = page.getMediaBox().getWidth() - (2 * margin);
      
          boolean drawContent = true;
          float yStart = yStartNewPage;
          float bottomMargin = 70;
          float yPosition = 550;
         cell = row.createTableCell((100), "", document, page, yPosition , bottomMargin, margin);   
      

      在表格内创建简单的表格单元格

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2021-12-16
      • 2017-09-08
      • 2018-05-03
      • 2015-03-19
      • 2019-02-14
      • 2018-03-20
      • 2017-09-12
      • 2013-07-04
      • 2018-02-15
      相关资源
      最近更新 更多