Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
Hi,
I am creating the pdf of the large tables dynamically. so i need to add a footer line and a page numbers to the document. i have applied code for it and it worked. but later i made some changes so it disappears and not coming back after reverting all the code too. so please tell me where i am doing the mistake.....
code for reference......
i declared the document in global with page size as,
C#
Document document = new Document(PageSize.A4, -60, -60, 30, 30);


i have added the class as following for itextsharp v 5.3.3

C#
public class FooterPDF : iTextSharp.text.pdf.PdfPageEventHelper
{
    int i = 0;
    public override void OnEndPage(PdfWriter writer, Document document)
    {        
        i += 1;
        //base.OnEndPage(writer, document);
        PdfPTable footerTable = new PdfPTable(1);
        footerTbl.TotalWidth = 216f;
        footerTable.TotalWidth = document.PageSize.Width;
        footerTable.LockedWidth = true;
        footerTable.SetWidths(widths);
        footerTable.HorizontalAlignment = Element.ALIGN_CENTER;
        Paragraph para = new Paragraph("© VIP FINANCIAL EDUCATION");
        PdfPCell cell = new PdfPCell(para); cell.Border = 1; cell.PaddingLeft = 10;
        footerTable.AddCell(cell);
        para = new Paragraph(i.ToString());
        cell = new PdfPCell(para);
        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        cell.Border = 0;
        cell.PaddingRight = 10;
        footerTable.AddCell(cell);        
        footerTable.WriteSelectedRows(20, -1, 10, footerTable.TotalHeight, writer.DirectContent);                   
    }
}
and nothing is working.
Posted
Updated 29-Oct-12 20:34pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900