When using TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(); my PDF comes up blank. Edit: I believe it is not rendering the styling, but I'm unsure how to solve it. We are using .xsl classes to style the HTML, whereas the GeneratePDF(); function expects to be passed a CSS class, OR it uses the default W3 styling. In theory, it should just work because out styling is all inline anyway (See the HTML sample I've attached below).
Source: PDFGenerator
I have tried rendering the HTML straight to PDF, and also HTML to a bitmap image, then to a PDF.
PdfDocument pdf = PdfGenerator.GeneratePdf(faxBody, PageSize.Letter,20,null,null,null);
string path = HostingEnvironment.MapPath("~/App_Data/mytestpdf.pdf");
pdf.Save(path);
And/Or
PdfDocument pdf = PdfGenerator.GeneratePdf(faxBody, PageSize.Letter,20,null,null,null);
Bitmap bitmap = new Bitmap(1200, 1800);
PdfPage page = new PdfPage();
XImage img = XImage.FromGdiPlusImage(bitmap);
pdf.Pages.Add(page);
XGraphics xgr = XGraphics.FromPdfPage(pdf.Pages[0]);
xgr.DrawImage(img, 0, 0);
string path = HostingEnvironment.MapPath("~/App_Data/mytestpdf.pdf");
pdf.Save(path);
I took the second snippet from another Stackoverflow thread to try. I get the same result either way: A blank PDF. The string "faxBody" definitely contains HTML here.
If I run this in the Immediate Window:
pdf.Save(HostingEnvironment.MapPath("~/App_Data/mytestpdf.pdf"));
I get this:
"Expression has been evaluated and has no value."
PDF: mytestpdf.pdf
HTML string: HTMLsample