小编xto*_*awn的帖子

如何在 React 中引用 pdf.js 库?

我正在尝试将PDF.js(由 Mozilla 提供)引用到我的 React 项目中。但是,它抛出“意外标识符”错误。

我已将 PDF.js 放在公共文件夹中并在我的 index.html 中引用它。

文件结构:

public
  - index.html
  - pdftojs
    - parsejs.js // < parseFile method in this file will be called
    - pdf-parse.js
    - misc..
src
  - pdftotext
    - parsepdf.js // < page to parse PDF

Run Code Online (Sandbox Code Playgroud)

pdf-parse.js

var PDFJS = null
function render_page(pageData) { ... } // Untouched
async function PDF(...) { ... } // Untouched

exports.pdf = PDF; // Changed this line
Run Code Online (Sandbox Code Playgroud)

来自原始库的 parsejs.js:

8    import pdf from 'pdf-parse.js';
9 …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs pdfjs

10
推荐指数
3
解决办法
8524
查看次数

标签 统计

javascript ×1

pdfjs ×1

reactjs ×1