first we create a class that in inherited by  PdfPageEventHelper and  i create a table in this class for footer content.

public partial class Footer : PdfPageEventHelper

{

public override void OnEndPage(PdfWriter writer, Document doc)

{

Paragraph footer= new Paragraph(“THANK YOU”, FontFactory.GetFont(FontFactory.TIMES, 10, iTextSharp.text.Font.NORMAL));

footer.Alignment = Element.ALIGN_RIGHT;

PdfPTable footerTbl = new PdfPTable(1);

footerTbl.TotalWidth = 300;

footerTbl.HorizontalAlignment = Element.ALIGN_CENTER;

PdfPCell cell = new PdfPCell(footer);

cell.Border = 0;

cell.PaddingLeft = 10;

footerTbl.AddCell(cell);

footerTbl.WriteSelectedRows(0, -1, 415, 30, writer.DirectContent);

}

}

after this

Document document = new Document(PageSize.A4, 50, 50, 25, 25);

var output = new FileStream(Server.MapPath(“Demo.pdf”), FileMode.Create);

PdfWriter writer = PdfWriter.GetInstance(document, output);

// Open the Document for writing

document.Open();

//using footer class

writer.PageEvent = new Footer();.

Paragraph welcomeParagraph = new Paragraph(“Hello, World!”);

document.Add(welcomeParagraph);

document.Close();

please contact me
email: gopalkaroli@gmail.com
skype Id: gd_gopal.singh

About these ads