We're using IronPdf to convert HTML to a PDF. Got it up and running pretty easily until I tried to add page numbers. Using the HtmlHeaderFooter with LoadStylesAndCSSFromMainHtmlDocument set to true more than doubles the rendering time.
Turning it off is an improvement, but an HTML page that takes 20 seconds to render without the footer takes 30 seconds with and another goes from 10 seconds to 16 seconds.
I thought perhaps just using TextHeaderFooters would be faster but those aren't showing up at all. Does anyone know how to get the text footer to show up correctly? Is there another property that needs to be set? Or how to get the HTML footer to not take so long?
This is a sample of the code I'm running:
public Stream ConvertToPdf()
{
License.LicenseKey = "...";
var chromePdfRenderer = new ChromePdfRenderer();
//This is really slow.
chromePdfRenderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
{
HtmlFragment = "<center>{page} of {total-pages}</center>"
};
//This doesn't show up
chromePdfRenderer.RenderingOptions.TextHeader = new TextHeaderFooter()
{
CenterText = "Ola mundo;",
FontSize = 12,
Font = FontTypes.Helvetica
};
using var pdf = chromePdfRenderer.RenderHtmlAsPdf("<h1>Hello World<h1>");
return pdf.Stream;
}
I've also tried this approach with similar results:
var renderer = CreateRenderer(reportModel);
using var pdfDocument = renderer.RenderHtmlAsPdf(html);
//Doesn't show.
pdfDocument.AddTextHeaders(CreateTextHeaderFooter());
//Really slow
pdfDocument.AddHtmlFooters(CreateHtmlHeaderFooter());
return pdfDocument.Stream;