ArthurHub / HTML-Renderer

Cross framework (WinForms/WPF/PDF/Metro/Mono/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library.
https://htmlrenderer.codeplex.com/
BSD 3-Clause "New" or "Revised" License
1.26k stars 527 forks source link

GeneratePdf(), returns an empty PdfDocument #202

Open Sercos10 opened 1 year ago

Sercos10 commented 1 year ago

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 :)

rblanca commented 9 months ago

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