IText - add content to the bottom of an existing page

I want to add a piece of text to each page of a PDF file. This answer in SO works great. But the text is added to the top of the page. I would like to add my text at the end of each page. How to do it?

Here is the relevant piece of code.

    while (iteratorPDFReader.hasNext()) {
        PdfReader pdfReader = iteratorPDFReader.next();

        // Create a new page in the target for each source page.
        while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {
            document.newPage();
            pageOfCurrentReaderPDF++;
            currentPageNumber++;
            page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF);
            cb.addTemplate(page, 0, 0);

            document.add(new Paragraph("My Text here"));  //As per the SO answer

        }
        pageOfCurrentReaderPDF = 0;
    }

The code is part of a function that takes a folder, reads PDF files into it, and combines them into a single file. Therefore, I would like to add text to the above loop, rather than repeating this file again.

0
source share
3 answers

6 iText , , 6.4.1: PDF-.

6.22 ConcatenateStamp.java , PDF- ( : ) PDF ; " X of Y"; , .

+2

, . 5 "iText - ". , . , .

, , . , " ", , - , : http://itextpdf.com/examples/iia.php?id=118

: , , ? . , . iText, !

, , . http://itextpdf.com/examples/iia.php?id=104

PdfPageEvent (, PdfPageEventHelper), onEndPage().

:

  • onStartPage() ,
  • Document, ,
  • , x = 0; y = 0. . y y .

.

+5

, ... , - :

cb.addTemplate(page, 0, 0);

document.add(new Paragraph("My Text here"));  
document.setFooter(new HeaderFooter("Footnote goes here"));
}
pageOfCurrentReaderPDF = 0;
0

All Articles