Hello,
I have a question in regards to headers for iText.
I am trying to write a custom header to the first page and a 'default'
header to every other page.
The header on the first page will always be larger in size (height) than the
default one.
I am NOT using document.setHeader( header ) at all; my main class extends
the PdfPageEventHelper, and I have both onStartPage and onEndPage
overridden. A relevant code snippet of onEndPage is shown below:
============================================================================
/**
*
* @param pWriter
* @param pDocument
*/
public void onEndPage( PdfWriter pWriter, Document pDocument )
{
// Write out our header first!
float lYCoordinate = pDocument.getPageSize().getHeight() -
pDocument.topMargin();
// float lYCoordinate = pDocument.getPageSize().getHeight() -
pDocument.topMargin() + aHeaderTable.getTotalHeight();
aHeaderTable.writeSelectedRows( 0, -1, pDocument.leftMargin(),
lYCoordinate, pWriter.getDirectContent() );
// Switch to default if we're done with the first page!
if( pWriter.getPageNumber() == 1 )
{
aHeaderTable = createDefaultHeader( pWriter, pDocument );
}
}
============================================================================
The class member aHeaderTable is of type PdfPTable and is initialized in the
main constructor with a method call to createFirstPageHeader( pWriter,
pDocument ).
I always want the header to start writing at the same height location, hence
the lYCoordinate variable. When I do this, however, the rest of my text
writes over the header and the effect is aesthetically displeasing. If I
include the table height in the y-Coordinate variable (the commented-out
declaration), it ends up writing the header off the page.
Any ideas how to resolve this?!
Any help is greatly appreciated.
Best regards,
John Kramer
--
View this message in context:
http://www.nabble.com/Custom-Headers-in-iText-PDF-tp24166704p24166704.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
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/