I am using the folllowing code to add a header and footer. It works fine
except that I am failing to align the text on the footer even after
using setAlignment(Element.ALIGN_MIDDLE);

Is there something I am missing? Please assist

 

 

 

  public void onEndPage(PdfWriter writer, Document document) {

     try {

     

       imgHeader  = Image.getInstance(strFontsDirectory +"image.gif");

       //not in use for now

       //dataProFooter  = Image.getInstance(strFontsDirectory
+"footer.jpg");

       

     //HEADER

         Rectangle page = document.getPageSize();

         PdfPTable head = new PdfPTable(1);

         PdfPCell cell = new PdfPCell(imgHeader  );

          cell.setBorderColor(Color.white)  ;

          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(1);

        arialFont           = new Font(baseFont,7.5f, 0,
Color.lightGray);

        Paragraph ph           = new
Paragraph(ProposalConstants.FOOTERTEXT, arialFont);

        ph.setAlignment(Element.ALIGN_MIDDLE);

        

        PdfPCell footerCell = new PdfPCell(ph);

         footerCell.setBorderColor(Color.red);

         footerCell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);

         footerCell.setVerticalAlignment(Element.ALIGN_JUSTIFIED);

 

         foot.addCell(footerCell);

         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);

     }

 }

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to