В конечном итоге это было достигнуто с помощью метода onEndPage PageEvent, приведенного ниже кода для справки
pw.openFile ();
pw.writer.setPageEvent(new PdfPageEventHelper(){
protected ApplicationContext applicationContext = ApplicationContext.getInstance();
@Override
public void onEndPage(PdfWriter writer, Document document)
{
PdfPTable table1=new PdfPTable(12);
try{
String accStr[] = null;
String accStr10[] = null;
accStr = new String[] { accountTitle ,"","","","","","Period Covered " ,startDate +" to " +endDate,"","","\u0645\u062f\u0629 \u0627\u0644\u062a\u063a\u0637\u064a\u0629",""};
accStr10 = new String[] {address1 ,"","","","","","Page No ",Integer.toString(writer.getPageNumber()-1),"","","\u0631\u0642\u0645 \u0627\u0644\u0635\u0641\u062d\u0629",""};
table1.setTotalWidth(522);
float f[] = {45,10,0,0,0,0,25,35,0,0,20,0};
table1.setWidths(f);
pw.setBorder = true;
pw.setBold = true;
pw.fontColour = AccStmtPDFWriter.COLOUR_BLACK;
pw.bgColour = AccStmtPDFWriter.COLOUR_WHITE;
pw.horAlignment = pw.ALIGN_LEFT;
PdfPCell pdfCell=null;
//table1=pw.getTable1();
if(!FieldNameUtil.isApplicableForBahrain){
pdfCell = new PdfPCell(new Phrase(new Chunk("")));
pdfCell.setBorder(0);
pdfCell.setColspan(12);
table1.addCell(pdfCell);
table1=writeHeaderLine(accStr, DataWriter.LINE_TYPE_GENERAL,table1);
}
pdfCell = new PdfPCell(new Phrase(new Chunk("")));
pdfCell.setBorder(0);
pdfCell.setColspan(12);
table1.addCell(pdfCell);
table1=writeHeaderLine(accStr10, DataWriter.LINE_TYPE_GENERAL,table1);
table1.writeSelectedRows(0, -1, 57, 730, writer.getDirectContent());
//document.add(table1);
table1.deleteBodyRows();
}catch(Exception e){
e.printStackTrace();
}
}
public PdfPTable writeHeaderLine(String line[], int type,PdfPTable table2)
throws Exception {
Chunk chunk = null;
PdfPCell cell =null;
PdfPTable tableNew =table2;
Font font=FontFactory.getFont("Arial",8,Font.BOLD,Color.BLACK);
try {
for (int i = 0; i < line.length; i++) {
//changed by shruti
if (line[i] == null)
chunk = new Chunk("", font);
else if(type==115 || (type==pw.LINE_TYPE_GENERAL && i>=line.length-2) || (type==112 && i==line.length-1)){
final String FONT = applicationContext.getProperty("arabic.font.path");
font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED,8);
if(line[i].equalsIgnoreCase("iban"))
font=FontFactory.getFont("Arial",8,Font.BOLD,Color.BLACK);
chunk = new Chunk(line[i], font);
}else
chunk = new Chunk(line[i], font);
cell = new PdfPCell(new Phrase(chunk));
cell.setBorder(Rectangle.NO_BORDER);
cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
if((type==pw.LINE_TYPE_GENERAL && i>=line.length-2)){
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
tableNew.addCell(cell);
}else{
tableNew.addCell(cell);
}
}
return tableNew;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
});