I do this on an EndPage event, seems to work fine

  /**
   * Inner class that adds headers and footers to page(s)
   */
  private class EndPage extends PdfPageEventHelper
  {

    public void onEndPage(PdfWriter writer, Document document)
    {
      try
      {
        Rectangle page = document.getPageSize();

        PdfPTable header = buildHeaderTable(document);
        header.writeSelectedRows(0, -1, document.leftMargin(),
page.getHeight()
            - (document.topMargin()) + header.getTotalHeight(),
writer.getDirectContent());

        PdfPTable footer = buildFooterTable(document);
        footer.writeSelectedRows(0, -1, document.leftMargin(), 38,
writer.getDirectContent());

      }
      catch (Exception e)
      {
        throw new ExceptionConverter(e);
      }
    }

  } 

-----Original Message-----
From: Eric B. [mailto:[email protected]] 
Sent: Wednesday, May 27, 2009 3:13 PM
To: [email protected]
Subject: [iText-questions] Any way to put a PdfPTable in a Header?

Hi,

I've got a table that I need repeated on every page.  I realize that I
could probably do this on a onStartPage event, but that would end up
breaking some existing code.  I was hoping to be able to simply create a
HeaderFooter object and include the table in there, but it seems that
HeaderFooters only accept Phrases or Chunks.

Is there anyway to put a Table in the header of the page, or is the
onStartPage really the only way possible?

Thanks,

Eric




------------------------------------------------------------------------
------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is
a gathering of tech-side developers & brand creativity professionals.
Meet the minds behind Google Creative Lab, Visual Complexity,
Processing, & iPhoneDevCamp as they present alongside digital
heavyweights like Barbarian Group, R/GA, & Big Spaceship.
http://p.sf.net/sfu/creativitycat-com
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/ You can also search the keywords list:
http://1t3xt.info/tutorials/keywords/





 
Email Confidentiality Notice: The information contained in this transmission is 
confidential, proprietary or privileged and may be subject to protection under 
the law, including the Health Insurance Portability and Accountability Act 
(HIPAA).

The message is intended for the sole use of the individual or  entity to whom 
it is addressed.  If you are not the intended recipient, you are notified that 
any use, distribution or copying of the message is strictly prohibited and may 
subject you to criminal or civil penalties.  If you received this transmission 
in error, please contact the sender immediately by replying to this email and 
delete the material from any  computer.
 
 

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to