Click here to Skip to main content
15,116,813 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am generating a pdf using html content.& i want to add footer except last page

What I have tried:

public override void OnEndPage(iTextSharp.text.pdf.PdfWriter writer, iTextSharp.text.Document document)
   {
       base.OnEndPage(writer, document);


PdfPTable tabFot = new PdfPTable(new float[] { 1F });
               PdfPCell cell;
               tabFot.TotalWidth = 250F;

               var FontColour = new BaseColor(68, 68, 132);
               var Calibri8 = FontFactory.GetFont("Calibri", 12, FontColour);

               cell = new PdfPCell(new Paragraph("Sign Here____________________", Calibri8));
               //cell = new PdfPCell(new Phrase("Sign Here____________________"));
               cell.Border = 0;

               tabFot.AddCell(cell);
               tabFot.WriteSelectedRows(0, -1, 40, 30, writer.DirectContent);


}
Posted
Updated 5-Mar-20 1:45am

1 solution

There is no way to know if you're on the last page when OnEndPage() is triggered, so you'll have to use a trick. Add a Boolean member-variable to your PDFFooter class and set it to false by default. Only add a footer when this member-variable is true


To make sure you have a footer for the pages that need one, set the member-variable to true after adding the coverpage and set it back to false before adding the endPage.
   

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