HTML-Renderer icon indicating copy to clipboard operation
HTML-Renderer copied to clipboard

GeneratePdf(), returns an empty PdfDocument

Open Sercos10 opened this issue 2 years ago • 1 comments

Hello i'm trying to generate a pdf via html string passed by parameter, my problem is that when i want to save the PdfDocument returned by the function, it doesn't have any pages or content (image of the debug is attached), here are the versions that i use:

Versions HtmlRenderer.Core: 1.5.1-beta1 HtmlRenderer.PdfSharp: 1.5.1-beta1 PdfSharp: 1.51.5185-beta

Here is the code of my function: var config = new PdfGenerateConfig(); config.PageOrientation = PageOrientation.Portrait; config.PageSize= PageSize.A4; PdfSharp.Pdf.PdfDocument pdf = PdfGenerator.GeneratePdf(html, config); pdf.Save(path);

image

image

And because it has no Pages and no content, i can't save it because it throws me the exception: 'Cannot save a PDF document with no pages'

Thank you in advantage :)

Sercos10 avatar Jun 07 '23 08:06 Sercos10

you have to combine it with PdfSharp latest version and use this HtmlRendererCoreNet7.PdfSharp

rblanca avatar Dec 09 '23 15:12 rblanca