I am 3 day old to ITEXT library. I went through the tutorial. I followed the example EndPage.java to create the header/footer.
 
The header is a 2 X 2 table. Footer is 1 X 3 table. In the header somehow the second row, first cell data is getting underlined and strike through. And all 3 cell data in the footer is also getting underlined and strickethrough. I am unable to figure out why. Any help will be much appreciated.
 
I am trying to insert a header/footer using the example given in the tutorial. Following is onEndPage code:
 
 public void onEndPage(PdfWriter writer, Document document) {
  try {
   Rectangle page = document.getPageSize();
   PdfPTable head = new PdfPTable(2);
   // header
   PdfPCell cell;
   cell = new PdfPCell(new Paragraph("ERA", FontFactory.getFont(
     FontFactory.TIMES, 12, Font.BOLD, Color.BLACK)));
   cell.setPadding(0f);
   cell.setBorder(0);
   cell.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
   head.addCell(cell);   
   cell = new PdfPCell(new Paragraph("EFT/Check #: " + eraCheckNo, FontFactory.getFont(
     FontFactory.TIMES, 10, Font.BOLD, Color.BLUE)));
   cell.setPadding(0f);
   cell.setBorder(0);
   cell.setHorizontalAlignment(Rectangle.ALIGN_RIGHT);
   head.addCell(cell); 
   
   cell = new PdfPCell(new Paragraph("ERA Amount :" + eraAmount, FontFactory.getFont(
     FontFactory.TIMES, 9, Font.DEFAULTSIZE, Color.GRAY)));
   cell.setPadding(0f);
   cell.setBorder(0);
   cell.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
   head.addCell(cell); 
   
   cell = new PdfPCell(new Paragraph("ERA Date: " + eraDate, FontFactory.getFont(
     FontFactory.TIMES, 9, Font.BOLD, Color.GRAY)));
   cell.setPadding(0f);
   cell.setBorder(0);
   cell.setHorizontalAlignment(Rectangle.ALIGN_RIGHT);
   head.addCell(cell); 
   
   head.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());   
   head.writeSelectedRows(0, -1, document.leftMargin(), page.height()
     - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());
   
   //footer
   PdfPTable foot = new PdfPTable(3);   
   cell = new PdfPCell(new Paragraph(practiceName, FontFactory.getFont(
     FontFactory.TIMES, 10, Font.DEFAULTSIZE, Color.BLACK)));
   cell.setPadding(0f);
   cell.setBorder(0);
   cell.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
   foot.addCell(cell);
   cell = new PdfPCell(new Paragraph("" + writer.getPageNumber(), FontFactory.getFont(
     FontFactory.TIMES, 10, Font.DEFAULTSIZE, Color.BLACK)));
   cell.setPadding(0f);
   cell.setBorder(0);
   cell.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
   foot.addCell(cell);   
   cell = new PdfPCell(new Paragraph("Created on: " + dateCreated, FontFactory.getFont(
     FontFactory.TIMES, 10, Font.DEFAULTSIZE, Color.BLACK)));
   cell.setPadding(0f);
   cell.setBorder(0);
   cell.setHorizontalAlignment(Rectangle.ALIGN_RIGHT);
   foot.addCell(cell);
   foot.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());   
   foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(), writer
     .getDirectContent());
  } catch (Exception e) {
   throw new ExceptionConverter(e);
  }
 }
 
Any help will be much appreciated.
Thanks in advance,
Rumpa Giri


Yahoo! Mail
Use Photomail to share photos without annoying attachments.

Reply via email to