If you know how to add extra space on the side as explained in this question: How to extend the page size of a PDF to add a watermark? then you should know how to add extra space to the bottom too. Your question is a duplicate.
The page size of a PDF document is defined using the /MediaBox
. It can be cropped using the /CropBox
. In the answer I gave, we change the /MediaBox
like this:
PdfArray mediabox = pageDict.getAsArray(PdfName.MEDIABOX);
llx = mediabox.getAsNumber(0).floatValue();
mediabox.set(0, new PdfNumber(llx - 36));
The value of llx
is the coordinate of the lower-left X-coordinate, and we subtract half an inch (36 user units).
If you want to change the bottom border, you have to change the lower-left Y-coordinate:
PdfArray mediabox = pageDict.getAsArray(PdfName.MEDIABOX);
lly = mediabox.getAsNumber(1).floatValue();
mediabox.set(1, new PdfNumber(llx - 36));
That's what Mark is doing in his answer to the question How do I resize an existing PDF with Coldfusion/iText
Of course, this won't have any effect if there's a crop box. If there's a crop box, you need to change the llx
value of the crop box too:
PdfArray cropbox = pageDict.getAsArray(PdfName.CROPBOX);
if (cropbox != null) {
lly = cropbox.getAsNumber(1).floatValue();
cropbox.set(1, new PdfNumber(llx - 36));
}
Obviously, you need to take the change into account when adding the footer. The bottom coordinate is no longer lly
but lly - 36
in my example.