【问题标题】:Convert pdf file to html file in JavaScript/jquery on client side?在客户端的 JavaScript/jquery 中将 pdf 文件转换为 html 文件?
【发布时间】:2016-05-25 15:32:58
【问题描述】:

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

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

也许有图书馆?

【问题讨论】:

    标签: javascript jquery html pdf


    【解决方案1】:

    我认为只有在 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);
    });
    

    或者,使用this software,它在命令行中很容易使用。

    【讨论】:

    • 我正在尝试在没有服务器端代码的情况下执行此客户端。我知道那里有服务器端实现
    【解决方案2】:

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

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

    还有 github 仓库

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

    【讨论】:

    • 是的,我尝试过使用它,但它会将 html 呈现给浏览器并且需要服务器,因此我无法获取文件中的 html 元素
    猜你喜欢
    • 2015-05-07
    • 2018-06-03
    • 2013-07-10
    • 2018-03-28
    • 1970-01-01
    • 1970-01-01
    • 2011-03-10
    相关资源
    最近更新 更多