Dominic Maricic wrote:

Hi Bruno, Thanks for the quick response. Can you point me to an example of
something similar? I'm a bit hazy on how it would work, though I've read
the entire tutorial at least 3 times now. PdfContentByte doesn't have a
getPageNumber(). Thanks for all of your hard work!
PdfWriter has a getPageNumber()
Create a Chunk x and do x.setGenericTag("dummy");
Add a PageEvent to your writer: writer.setPageEvent(new MyPageNumber());

This is an untested implementation (written from memory, so it might not compile):

public class MyPageNumber extends PdfPageEventHelper {

public static final BaseFont BF = BaseFont.createFont("Helvetica", "winansi", BaseFont.NOT_EMBEDDED);

public void onGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) {
   PdfContentByte cb = writer.getDirectContent();
   cb.beginText();
   cb.setFontAndSize(BF, 11);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, String.valueOf(writer.getPageNumber(), rect.left(), rect.bottom()));
   cb.endText();
 }
}


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to