Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a PDFPTable to bottom of page in iText

Tags:

java

itext

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);
like image 277
Batman Avatar asked Dec 04 '22 14:12

Batman


1 Answers

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

Examples:

  • 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.
like image 135
Bruno Lowagie Avatar answered Dec 30 '22 21:12

Bruno Lowagie