我正在尝试将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)