【问题标题】:Header using Itext使用 Itext 的标题
【发布时间】:2013-09-19 07:01:48
【问题描述】:
ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(headerContent,headerFont) ,document.right() - 300, document.top() + 5, 0);

我有这行代码。对于 A4 纸张大小,我将页眉放在页面的中心,但对于 A3、A2、A1,我将它放在页面的左侧。我应该怎么做才能得到它所有纸张尺寸(A4、A3、A2、A1)的页面中心。

【问题讨论】:

  • 您是如何使用document.right() - 300 作为参考x 坐标的? 300 引入了格式依赖性。

标签: html pdf itext


【解决方案1】:

您应该使用(document.left() + document.right()) / 2 作为x 值。 至于y 的值,你应该使用document.top() - (headerFont.getSize() * 1.5f)。据我所知document.top() + 5 会在实际页面上方的不可见区域中添加文本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-13
    • 1970-01-01
    • 2015-07-12
    相关资源
    最近更新 更多