【问题标题】:SyntaxError: Parse error - Wkhtmltopdf with react-pdf-js libSyntaxError:解析错误 - 带有 react-pdf-js 库的 Wkhtmltopdf
【发布时间】:2016-09-18 00:22:50
【问题描述】:

我正在使用 wkhtmltopdf 版本 0.12.2.1(带有修补的 qt)来渲染我的 reactJs 应用程序!它工作得很好,直到我添加了react-pdf-js lib 来呈现我的应用程序中生成的 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 脚​​本的一部分。

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

谢谢..

【问题讨论】:

标签: qt pdf reactjs wkhtmltopdf pdfjs


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-16
    • 2022-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 2011-05-24
    • 1970-01-01
    相关资源
    最近更新 更多