How to make a footer constant in a dynamic pdf page?

29 Views Asked by At

I have a pdf page, lets say I have 3 of them. Now, some will have 10 rows, while some will have a table, and some will have a single row. ( just as an example ).

I'm trying to generate the footer each page using (ironpdf), doing:

 private void AddFooterNextPages2(IronPdfUtil pdfUtil, string carNumber, string queryDate)
 {

     Font regularFont = PdfUtil.generateFont(PdfUtil.GetFont(), 9f, Font.BOLD);
     var text = Properties.Resources.sheiltaLerechv + carNumber + " " + Properties.Resources.mtaarich + queryDate + " " + Properties.Resources.anmod + " " + pdfUtil.currentPageNumber;

     // Define the footer HTML with inline CSS for fixed bottom positioning
     var footerHtml = $"<div style='position: fixed; bottom: 0; width: 100%; text-align: center; font-weight: bold; font-family: david; font-size: {regularFont.Size}pt;'>{text}</div>";

     //Insert the footer HTML into the PDF as HTML content
     pdfUtil.InsertElementAtTheEnd(XElement.Parse(footerHtml));
 }

I have an event that triggers that one, when I decided the page is over. The thing is, the position will indeed be fixed, but the row will override each other for each page.

So, lets say page 2 will have just

var text = Properties.Resources.sheiltaLerechv + carNumber + " " + Properties.Resources.mtaarich + queryDate + " " + Properties.Resources.anmod + " " + pdfUtil.currentPageNumber;

Then lets say I invoked the event as I'm done with page 2, and I raised the counter to 3. Now what will happen is that both of the footers will be on top of each other and will create a messy line of text.

Any way to avoid?

0

There are 0 best solutions below