Search code examples
c#htmlasp.net-mvcpdfselectpdf

SelectPDF missing content after conversion


So I am using SelectPDF to convert an MVC view's html to PDF, but for some reason, a great deal of the content is missing from the PDF.

I have tested the program on other sites I have made in MVC and they work...

So as per the readme doc's recommendation, I use this code to produce a

SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
SelectPdf.PdfDocument doc = converter.ConvertUrl(HTMLPath);
//SelectPdf.PdfDocument doc = converter.ConvertHtmlString(ViewHTML);

doc.Save(PDFSavePath);
doc.Close();

So HTMLSave path is the location of the HTML file created from the rendered MVC view. While ViewHTML contains the HTML in the form of a string.

So this is how the HTML looks (the file and the view look identical, I did double check in case the HTML was captured incorrectly):

HTML

But this is how the PDF looks:

PDF Absolutely tragic...

Not sure if it will be helpful, but here's the HTML:

https://drive.google.com/open?id=0B8DiACLG11oYd3p5Tzc2ZlJQLVk

Unfortunately, all the HTML is on one line thanks to the MVC View to HTML


Solution

  • It seems that the html/css engine used to render the page does not support vh, vw for font sizes. It's a common issue with all converters, so probably you should try to change this if you need the page converted to pdf.

    Later update: it seems that there is support for vw, but not for vh. That's why the "each" words appear. They use vw in css.