Can you have multiple footers on a HTML generated PDF document?

Hi all

I'm trying to render a PDF document based of a HTML string.

PdfDocument document = htmlConverter.Convert(source);

So far so good, pages render fine. I can even make a separate footer to be used on the document:

WebKitConverterSettings settings = new WebKitConverterSettings();
settings.PdfFooter = new PdfPageTemplateElement(rect);

Unfortunately I want to show two different footers - one on the first page and a different on the rest. According to the documentation this is done using page sections. But all documentation on sections assumes each pages is added to section as part of the render of the page, which is not the case with the HTML generated content. I've tried to remove the page from on section and then add it to a different page but without any luck.

This fails claiming the removed page is still part of a section and hence can't be added to a different section:
                document.Sections.Add();
                var page = document.Sections[0].Pages[1];
                document.Sections[0].Pages.Remove(page);
                document.Sections[1].Pages.Add(page);

Any suggestions?

Cheers,
Mads Anton​



1 Reply

PV Prakash Viswanathan Syncfusion Team November 4, 2021 08:01 AM UTC

Hi Mads Anton, 

Thank you for contacting Syncfusion support.  

We can have multiple header/footer in a PDF document, but we do not have direct support for adding multiple header/footer in a PDF document. As a workaround, we can create different header/footer templates and draw it to PDF pages directly instead of using PdfHeader/PdfFooter/Section properties.  

Please refer below links for creating and drawing the PdfTemplate to PDF document, 

We can create multiple templates (headers/footers) and draw it to the converted PDF document from HTML converter. We have to reserve a white space for header/footer during the HTML conversion using top and bottom margin. After the conversion, we can load the converted document and draw the template to white space which is reserved earlier. Kindly try this workaround and let us if it suites to your requirement.   

Regards, 
Prakash V 


Loader.
Up arrow icon