1

我正在使用 wkhtmltopdf 版本 0.12.2.1(带有修补的 qt)来渲染我的 reactJs 应用程序!它工作得很好,直到我添加了react-pdf-js库来渲染我的应用程序中生成的 pdf。我按照 react-pdf-js 文档中描述的代码(参见https://www.npmjs.com/package/react-pdf-js)使其工作。

pdf 在我的页面中呈现,看起来确实很酷。但是当我再次尝试运行 wkhtmltopdf 以生成我的应用程序的任何页面的 pdf 时,会返回以下错误:

desenv01@desenv01-PC:~$ wkhtmltopdf -O Landscape --print-media-type --debug-javascript  http://localhost:3000/report/1 report.pdfLoading pages (1/6)
Warning: undefined:0 ReferenceError: Can't find variable: Float64Array
Warning: http://localhost:3000/assets/js/app.js:46789 SyntaxError: Parse error
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done

然后,我去我的 app.js 看看第 46789 行有什么:

    set href(href) {
      clear.call(this);
      parse.call(this, href);
    },

    get protocol() {
      return this._scheme + ':';
    },
    set protocol(protocol) {
      if (this._isInvalid)
        return;
      parse.call(this, protocol + ':', 'scheme start');
    },

错误发生在说 的行上parse.call(this, href);,这是pdf.combined.js脚本的一部分。

我在网上找不到任何解决方案,所以我想知道是否有人可能知道我是否做错了什么或有办法解决它。

谢谢..

4

1 回答 1

2

我遇到了这个 usingwkthmltopdf 12.3并且12.4因为我的 IDE 设置为使用var而不是let. 问题是为这些版本的程序提供动力的旧 Qt 引擎无法识别新样式的 ES6 关键字。不确定你是否可以下转换 React。否则,您可以尝试使用较新 Qt 的前沿版本。

于 2017-06-09T19:44:16.583 回答