【问题标题】:Adjusting Table Column Width using iText Library in JavaScript, xPages在 JavaScript、xPages 中使用 iText 库调整表格列宽
【发布时间】:2013-04-04 19:24:40
【问题描述】:

在 xPages 中使用 iText 库,如何调整列宽?如果我使用 table.setWidths(30,10,30),我得到以下错误:error: com.ibm.jscript.InterpretException: Script interpreter error, line=52, col=7: Java method 'setWidths(number, number , number)' on java class 'com.itextpdf.text.pdf.PdfPTable' not found

【问题讨论】:

  • Brian M Moore 的一个有价值的技巧最终奏效了(将参数作为数组传递) var table = new com.itextpdf.text.pdf.PdfPTable(3); // 3 列。变量宽度:浮动= [150f,100f,150f]; table.setTotalWidth(宽度); table.setLockedWidth(true); var cell1 = new com.itextpdf.text.pdf.PdfPCell(new com.itextpdf.text.Paragraph("表格单元格 1")); var cell2 = new com.itextpdf.text.pdf.PdfPCell(new com.itextpdf.text.Paragraph("表格单元格 2")); var cell3 = new com.itextpdf.text.pdf.PdfPCell(new com.itextpdf.text.Paragraph("Table Cell 3"));

标签: javascript itext xpages


【解决方案1】:

将您的代码包装到一个Java类中,该类只需要调用一个函数,并将流和文档作为参数

【讨论】:

    【解决方案2】:

    看起来 setWidths 需要浮点数。这行得通吗?

    table.setWidths(parseFloat(30),parseFloat(10),parseFloat(30))

    【讨论】:

    • 使用 table.setWidths(parseFloat(30),parseFloat(10),parseFloat(30)),我仍然得到同样的错误。
    猜你喜欢
    • 2010-10-22
    • 2021-12-29
    • 1970-01-01
    • 2021-02-10
    • 2017-08-04
    • 2015-11-09
    • 2023-03-11
    • 1970-01-01
    • 2018-08-11
    相关资源
    最近更新 更多