【问题标题】:How to import an existing PDF file in node.js如何在 node.js 中导入现有的 PDF 文件
【发布时间】:2017-05-06 14:27:37
【问题描述】:

我正在研究节点的导入例程,到目前为止,我可以使用 pdf2json 从 PDF 导入文本节点,这很好用,但不适用于基于图像且不包含文本的 PDF。

所以我下载了 pdf2img,但是这个模块有很多问题,我现在遇到的问题是,运行它后,我创建了很多 0 字节的 png 文件,没有内容和错误消息:

    /docfire/node_modules/gm/lib/command.js:228
        proc.stdin.once('error', cb);
                  ^

    TypeError: Cannot read property 'once' of undefined
        at gm._spawn (/docfire/node_modules/gm/lib/command.js:228:15)
        at /docfire/node_modules/gm/lib/command.js:140:19
        at series (/docfire/node_modules/array-series/index.js:11:36)
        at gm._preprocess         

(/docfire/node_modules/gm/lib/command.js:177:5) 在 gm.stream (/docfire/node_modules/gm/lib/command.js:138:10) 在 convertPdf2Img (/docfire/node_modules/pdf2img/lib/pdf2img.js:93:6) 在 /docfire/node_modules/pdf2img/lib/pdf2img.js:67:9 在 /docfire/node_modules/async/lib/async.js:246:17 在 /docfire/node_modules/async/lib/async.js:122:13 在 _each (/docfire/node_modules/async/lib/async.js:46:13)

我已尝试在 GIT 网站上发布该模块的问题,但似乎有不少人遇到了完全相同的问题,而且似乎没有任何有关任何修复的活动。

理想情况下,我想要一种从 PDF 中提取文本和图像以用于节点的方法。

我在运行 macOS Sierra v10.12.4 的 iMAC 上运行 使用节点版本 7.8.0,pdf2img 0.2.0,gm 1.23.0

【问题讨论】:

    标签: node.js pdf import


    【解决方案1】:

    你可以试试 pdf-image npm 包。

    https://www.npmjs.com/package/pdf-image

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-11-22
      • 2011-06-07
      • 1970-01-01
      • 2016-07-02
      • 2011-03-24
      • 2015-05-06
      • 2020-09-23
      • 2020-12-26
      相关资源
      最近更新 更多