Need to render html content as header in Pdf export

22 Views Asked by At

I am using Pdfsharp v6.0.0 library and need to render header and footer to the pdf document.

My requirement is that I need to render ``` ```` content of html as header in the pdf. I tried that using html HtmlRenderer.PdfSharp v 1.5.0.6 to achieve this. I was using below code to achieve this

HtmlRenderer.PdfSharp.HtmlContainer container = new HtmlRenderer.PdfSharp.HtmlContainer();
container.SetHtml(headerHtml);
container.MaxSize = new XSize(page.Width, page.Height);
container.PerformLayout(gfx);

container.Arrange(new XRect(0, 0, page.Width, page.Height));
container.Paint(gfx);

however I notice that container.MaxSize throws error of incompatibility between Pdfsharp and HtmlRenderer.PdfSharp as Htmlrenderer expects it to be 1.3.2 v.

Can anyone please help me how to achieve this in the latest version of Pdfsharp. ?

Also any other library to render html content to pdfsharp for header and footer.?

0

There are 0 best solutions below