Rectangle page = document.getPageSize();
PdfPTable head = new PdfPTable(3);
for (int k = 1; k <= 6; ++k)
head.addCell("head " + k);
head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(),
writer.getDirectContent());
PdfPTable foot = new PdfPTable(3);
for (int k = 1; k <= 6; ++k)
foot.addCell("foot " + k);
foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());