首页 文章

在客户端 JavaScript/jquery 中将 pdf 文件转换为 html 文件?

提问于
浏览
0

有没有办法使用 JavaScript 或 jquery 将 pdf 文件转换为 html 文件?这可以在客户端完成并在本地运行吗?

到目前为止,我只找到了像 pdf2htmlEX 这样的服务器端解决方案

也许有图书馆?

2 回答

  • 2

    我认为只在 nodejs 中。你可以跑

    npm install pdftohtmljs
    

    然后在您的服务器代码中:

    var pdftohtml = require('pdftohtmljs');
    var converter = new pdftohtml('file.pdf', "file.html");
    
    // see https://github.com/fagbokforlaget/pdftohtmljs/blob/master/lib/presets/ipad.js 
    converter.convert('ipad').then(function() {
      console.log("converted");
    }).catch(function(err) {
      console.log(err);
    });
    

    或者,使用易于从命令行使用的这个软件

  • 0

    我怀疑这是可能的。也许 Mozilla 的 PDF.js 可以让你朝着正确的方向前进:

    https://mozilla.github.io/pdf.js/

    和 github 回购

    https://github.com/mozilla/pdf.js

相关问题