【问题标题】:Any replacement function for ActiveXobject in Chrome?Chrome 中 ActiveXobject 的任何替换功能?
【发布时间】:2018-06-20 14:26:41
【问题描述】:

嘿,我有一些与将一些旧的 .hta 应用程序转移到 chrome 相关的问题。 Chrome中是否有任何替换功能,我可以从pdf文件链接解析pdf文件: 我的旧 java 脚本是:

    var PDFDoc = new ActiveXObject("AcroExch.AVDoc");
    if (PDFDoc.Open(filePath, "")) {
        //PDFDoc.BringToFront;
        //PDFApp.Show();
    }
    else { 
        alert("Invalid file path for opening a PDF");
        return false;
    }
    var PDDoc = PDFDoc.GetPDDoc();
    var jso = PDDoc.GetJSObject();
    var extractor = function (fieldName) { 
        if (jso.getField(fieldName) != null) {return jso.getField(fieldName).Value;} else {return "";}
    };
    return extractor;

【问题讨论】:

  • 当然有。谷歌“在浏览器的 javascript 中解析 pdf”
  • @Keith:pdf.js 似乎只支持渲染 pdf,不支持解析字段
  • node.js 的 pdf2json 项目似乎很有希望:github.com/modesty/pdf2json
  • @Greg 来自网站 -> A general-purpose, web standards-based platform for parsing and rendering PDFs. 请注意 parsing 这个词,不过我看到的主要问题是文档很烂。 :)

标签: javascript html web hta


【解决方案1】:

正如@Keith 所建议的,请看以下示例:https://github.com/mainegreen/pdf.js/tree/master/examples/forms

您必须修改 index.html 才能使其正常工作。 在页面底部添加:

    ...
    </div>
    <div id="showHere"></div>
</div>
<script>FormsDemo.loadPdf('showHere', 'f1040.pdf');</script>
</body>

这将加载并呈现演示 PDF。按“显示所有数据!”显示所有表单元素的列表。您可以在 PDF 中输入值,这些值将反映在元素列表中。

【讨论】:

    猜你喜欢
    • 2020-06-07
    • 1970-01-01
    • 2018-09-30
    • 2017-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-17
    • 2013-05-18
    相关资源
    最近更新 更多