I got an 'System.InvalidOperationException' and message 'Cannot save a PDF document with no pages.'
I generate a PdfDocument with TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.Letter), and the html has contents, but the PdfDocument is empty and cause a 'System.InvalidOperationException' when i save the document by pdf.Save(memoryStream)
@denghuichao Any luck with this error
Same situation for me
Same for me when using in a Azure Function
Hi guys, same issue for but only for first load of the application, any fix on this?
any update on this? I'm having the same error reading an html file
I was also getting this error, and I believe it was due to my Bootstrap column layout. Bootstrap puts display: flex; on elements with class="row", and HtmlRenderer doesn't seem to handle that well.
Here's a minimal reproduction; this code throws "System.InvalidOperationException: Cannot save a PDF document with no pages".
var htmlString = @"<div class=""row"">Hello, world!</div>";
var styleSheet = @".row { display: flex; }";
var pdf = PdfGenerator.GeneratePdf(
html: htmlString,
pageSize: PageSize.Letter,
cssData: PdfGenerator.ParseStyleSheet(styleSheet));
pdf.Save("PdfSharp_FlexLayout.pdf");
I'm afraid I don't have a workaround at this time.
@benj2240 have you found a solution for this bug?
@cfrancoluna I'm afraid not. I had to take my project in a different direction.
@benj2240 Ok thank for your time