【问题标题】:SelectPDF not Showing Grid DataSelectPDF 不显示网格数据
【发布时间】:2020-06-19 12:41:25
【问题描述】:

我正在使用Select PDF - Community Edition 来呈现网页的输出(例如文档)。当我查看 PDF 时...网格中的数据是空的。

  • 是的,网格数据在正常查看时会呈现
  • 附带说明...我正在使用 Kendo Grids

作为一个实验...我将"MinPageLoadTime" 属性设置为 15 秒...确实需要 15 秒才能执行 SAVE...但奇怪的是,在 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;
}

PDF 中没有网格数据:

【问题讨论】:

    标签: c# selectpdf


    【解决方案1】:

    免责声明:我为 SelectPdf 工作。

    这可能是一个 javascript 错误。尝试使用 converter.ConversionResult.ConsoleLog 获取转换后的控制台日志。查看是否有任何 javascript 错误。

    • 旧版本中不存在 ConsoleLog 对象
    • 只需升级到列出的最新版本here

    SelectPdf 支持多个rendering engines。默认的 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多