Sumner, Jeff wrote:
> It looks like headers should be generated in the onEndPage method
> instead of onStartPage.
That's correct.
> First, as I generate body text of the document, I’d need to set the top
> margin based on the page number. If I’m on page 1, I need 3.5 inches
> for the header. Otherwise I need only 2 inches. Is it possible to call
> Document.setMargins() in the onStartPage method to conditionally change
> the top margin based on the current page?
I wouldn't do that. The Document object you receive in onStartPage
is a PdfDocument NOT the Document object you're adding content to.
> Second, and this is the one that really concerns me, is it possible to
> use the PdfPTable objects to generate my header data and make calls
> document.add(table) to build the header?
No, for the same reason as above.
> Or do I have to use the
> PdfContentByte class and generate everything with absolute positions?
> I’m afraid that the answer is that I have to use PdfContentByte, but
> I’m hoping that’s not the case since I already have everything working
> with the PdfPTables.
This seems like a perfect job for ColumnText.
That way you can keep on working with PdfPTable.
You can avoid working with PdfContentByte directly.
In PseudoCode:
Document.open();
ColumnText ct1 = new ColumnText(writer.getDirectContent());
ColumnText ct2 = new ColumnText(writer.getDirectContent());
ct1.setSimpleColumn(coordinates);
ct2.setSimpleColumn(coordinates);
while (there's content) {
ct1.add(header_table);
ct1.go();
ct2.add(content);
ct2.setY(ct1.getY());
ct2.go();
document.newPage();
}
(This is NOT a working example, just something meant to inspire you.)
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-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/