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();
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"));
}
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.
source
share