所以我使用SelectPDF将MVC视图的html转换为PDF,但由于某些原因,PDF中缺少大量内容。
我已经在我在MVC上制作的其他网站上测试了这个程序,但是它们有效......
根据自述文件的推荐,我使用此代码生成
SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
SelectPdf.PdfDocument doc = converter.ConvertUrl(HTMLPath);
//SelectPdf.PdfDocument doc = converter.ConvertHtmlString(ViewHTML);
doc.Save(PDFSavePath);
doc.Close();
所以HTMLSave
路径是从渲染的MVC视图创建的HTML文件的位置。虽然ViewHTML
包含字符串形式的HTML。
这就是HTML看起来的样子(文件和视图看起来完全相同,我在不正确地捕获HTML的情况下进行了双重检查):
但这就是PDF的外观:
不确定它是否有用,但这里是HTML:
https://drive.google.com/open?id=0B8DiACLG11oYd3p5Tzc2ZlJQLVk
不幸的是,由于MVC View to HTML
,所有HTML都在一行上答案 0 :(得分:1)
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.