在iText中将PDFPTable添加到页面底部 [英] Add a PDFPTable to bottom of page in iText

查看:1069
本文介绍了在iText中将PDFPTable添加到页面底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加一个包含所有版权文本,页码等的页脚。但是我找不到任何支持 PdfPTable

I'm trying to add a table as a footer containing all the copyright text, page number etc. But I can't find any supporting method that'll accept a PdfPTable

对于短语,有如下代码:

For a phrase there is code like:

ColumnText.showTextAligned(writer.getDirectContent(),
        Element.ALIGN_CENTER, new Phrase(
            String.format("%d", document.getPageNumber())),
            (document.getPageSize().getLeft() + document.getPageSize().getRight())/2,
            document.getPageSize().getBottom() + 18, 0);


推荐答案

PdfPTable class有一个方法 writeSelectedRows(),可用于在绝对位置添加(选择列和行)。

The PdfPTable class has a method writeSelectedRows() that can be used to add (a selection of columns and) rows at an absolute position.

示例:

  • http://itextpdf.com/examples/iia.php?id=89 adds rows at an absolute position.
  • http://itextpdf.com/examples/iia.php?id=90 adds a selection of columns/rows at an absolute position.
  • http://itextpdf.com/examples/iia.php?id=91 an alternative solution where you wrap a table in a ColumnText object.

这篇关于在iText中将PDFPTable添加到页面底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆