c# - SelectPDF 不显示网格数据
问题描述
我正在使用Select PDF - Community Edition来呈现网页的输出(例如文档)。当我查看 PDF 时……网格中的数据是空的。
- 是的,网格数据在正常查看时会呈现
- 作为旁注......我正在使用剑道网格
作为一个实验......我将“MinPageLoadTime”属性设置为 15 秒......执行 SAVE 确实需要 15 秒......但奇怪的是,在 PDF 的网格渲染中仍然没有显示任何记录。
public byte[] ToPDF(IPdfConverterArgs args)
{
if (args == null)
throw new ArgumentNullException();
if (!(args is SelectPdfUrlConverterArgs))
throw new ArgumentException(string.Format("Args.Type '{0}' is not a valid type.", typeof(SelectPdfUrlConverterArgs).Name));
var arguments = args as SelectPdfUrlConverterArgs;
if (string.IsNullOrWhiteSpace(arguments.Url))
throw new ArgumentNullException();
var pdfPageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), arguments.PdfPageSize, true);
var pdfOrientation = (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation), arguments.PdfOrientation, true);
HtmlToPdf converter = new HtmlToPdf();
converter.Options.PdfPageSize = pdfPageSize;
converter.Options.PdfPageOrientation = pdfOrientation;
converter.Options.WebPageWidth = arguments.WebPageWidth;
converter.Options.WebPageHeight = arguments.WebPageHeight;
converter.Options.MinPageLoadTime = arguments.MinPageLoadTime; //<<< In my testing...I temporarily set this to 15 (for seconds)
PdfDocument doc = converter.ConvertUrl(arguments.Url);
var bytes = doc.Save();
return bytes;
}
解决方案
免责声明:我为 SelectPdf 工作。
这可能是一个 javascript 错误。尝试使用converter.ConversionResult.ConsoleLog获取转换后的控制台日志。查看是否有任何 javascript 错误。
- 旧版本中不存在 ConsoleLog 对象
- 只需升级到此处列出的最新版本
SelectPdf 支持多种渲染引擎。默认的 WebKit 渲染引擎可以渲染 ES5 javascript。较新的 ES6 javascript 语法可能会导致错误。
HtmlToPdf converter = new HtmlToPdf();
converter.Options.PdfPageSize = pdfPageSize;
converter.Options.PdfPageOrientation = pdfOrientation;
converter.Options.WebPageWidth = arguments.WebPageWidth;
converter.Options.WebPageHeight = arguments.WebPageHeight;
converter.Options.MinPageLoadTime = arguments.MinPageLoadTime;
PdfDocument doc = converter.ConvertUrl(arguments.Url);
// At this point...you can look at the ConsoleLog object off of the ConversionResult to find any JavaScript Errors
推荐阅读
- ios - 元数据被拒绝 附表 2,第 3.8(b) 节
- oracle - 无法连接到在 Docker 中的 Oracle 数据库 18 XE 上创建的新用户
- mysql - 错误 1366 (HY000):不正确的整数值:第 1 行的列“Industry_Code”的“6029”不知道这是为什么?
- android - 可以在android中使用guice吗?
- wordpress - WordPress 主菜单链接有项目符号并且不是水平的
- firebase - 通过 Flutter 应用使用 Firebase 登录谷歌
- javascript - 我如何在 Spring Boot 中使用这个图表 js?
- flutter - 如何在颤动中知道以前的路线名称?
- python - 如何使用 pickle 模块更新记录?
- android - Gradle:compileOnly 和 runtimeOnly