iTextSharp 5.0 Footer is not displaying
Posted
by Rick Make
on Stack Overflow
See other posts from Stack Overflow
or by Rick Make
Published on 2010-04-03T00:48:56Z
Indexed on
2010/04/03
0:53 UTC
Read the original article
Hit count: 941
itextsharp
I am trying to create a simple footer that would display on the bottom of each page of the pdf document. I created a class that inherits from PdfPageEventHelper and it is set properly because the OnEndPage() method is called. But my temporary footer is not displaying. Is there something wrong that I am doing in my OnEndPage() method:
public override void OnEndPage(PdfWriter writer, Document document)
{
base.OnEndPage(writer, document);
int pageN = writer.PageNumber;
String text = "Page " + pageN + " of ";
float len = bf.GetWidthPoint(text, 8);
Rectangle pageSize = document.PageSize;
cb.SetRGBColorFill(100, 100, 100);
cb.BeginText();
cb.SetFontAndSize(bf, 8);
cb.SetTextMatrix(pageSize.GetLeft(40), pageSize.GetBottom(30));
cb.ShowText(text);
cb.EndText();
cb.AddTemplate(template, pageSize.GetLeft(40) + len, pageSize.GetBottom(30));
cb.BeginText();
cb.SetFontAndSize(bf, 8);
cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT,
"Printed On " + PrintTime.ToString(),
pageSize.GetRight(40),
pageSize.GetBottom(30), 0);
cb.EndText();
}
© Stack Overflow or respective owner