I'm sorry to ask something that appears so frequently, but I can't seem to 
get it to work. I want to put a large amount of information in the header 
on the first page and a smaller amount in each successive page. I've read 
all I can find and everyone says 'put it in the onEndPage event'. 

I have a class GenerationService that builds my pdf. In it there is a 
nested class HeaderManager extends PdfPageEventHelper to manage the 
headers. In GenerationService there is a getBigHeader(args) and a 
getLittleHeader(args). They work; I've tried Table.setHeaderRows(2) and 
PdfPCell headerCell = new PdfPCell(getBigHeader(args)); 
docTable.addCell(headerCell); as the first lines in the document assembly 
process and I get what I want to see. Similarly for getLittleHeader. 

My onEndPage event looks like this:
try {
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(4);
        if (document.getPageNumber() == 1){
                head.addCell(getBigHeader(theCsi, theCert));
        } else {
                head.addCell(getLittleHeader(theCsi, theCert));
        }
        System.out.println ("LdCsiHeaderManager:onEndPage: 
head.getTotalHeight()=" + head.getTotalHeight());
        head.setTotalWidth(page.getWidth() - document.leftMargin() - 
document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(), 
page.getHeight() - document.topMargin() +
                head.getTotalHeight(), writer.getDirectContent());
      }

I've pulled out a lot of System.out.println's that I've been using to 
instrument the code. I've seen enough to know that the plumbing works; the 
events don't start to fire until the document is assembled, and my event 
can see global vars outside the nested class. The s.o.p. for the 
getTotalHeight always returns zero. 

Does anyone have any suggestions? Do you need more information? Thanks in 
advance - dan fox

Daniel Fox
CDX
Verify / OTAQ / ODS / CROMERR
(and others as needed)
CSC

8400 Corporate Drive, Suite 150  New Carrollton, MD  20785
EPA CDX Program I p: 1-301-429-5081 I f: 301-429-4860 I d...@csc.com I 
www.csc.com

This is a PRIVATE message. If you are not the intended recipient, please 
delete without copying and kindly advise us by e-mail of the mistake in 
delivery. 
NOTE: Regardless of content, this e-mail shall not operate to bind CSC to 
any order or other contract unless pursuant to explicit written agreement 
or government initiative expressly permitting the use of e-mail for such 
purpose.
------------------------------------------------------------------------------
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 asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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