使用javascript / jquery获取docx文件内容 [英] get docx file contents using javascript/jquery

查看:1256
本文介绍了使用javascript / jquery获取docx文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望使用客户端技术(HTML / JS)打开/读取docx文件。

wish to open / read docx file using client side technologies (HTML/JS).

如果可能,请提供帮助。找到了一个名为docx.js的Javascript库,但个人似乎无法找到它的任何文档。
http://blog.innovatejs.com/?p=184

kindly assist if this is possible . have found a Javascript library named docx.js but personally cannot seem to locate any documentation for it. (http://blog.innovatejs.com/?p=184)

目标是为docx文件和txt文件制作基于浏览器的搜索工具。

the goal is to make a browser based search tool for docx files and txt files .

任何帮助表示赞赏。

推荐答案

使用 docxtemplater ,您可以使用doc.getFullText()方法轻松获取单词的全文(仅适用于docx)。

With docxtemplater, you can easily get the full text of a word (works with docx only) by using the doc.getFullText() method.

<script src="build/docxgen.js"></script>
<script src="vendor/FileSaver.min.js"></script>
<script src="vendor/jszip-utils.js"></script>
<script>
    var loadFile=function(url,callback){
        JSZipUtils.getBinaryContent(url,callback);
    }
    loadFile("examples/tagExample.docx",function(err,content){
        var doc=new Docxgen(content);
        text=doc.getFullText();
        console.log(text);
    });
</script>



获取源代码:



Getting the source code:

git clone https://github.com/edi9999/docxtemplater.git && cd docxtemplater
# git checkout v1.0.4 # Optional
npm install -g gulp jasmine-node uglify-js browserify
npm install
gulp allCoffee
mkdir build -p
browserify -r ./js/docxgen.js -s Docxgen > build/docxgen.js
uglifyjs build/docxgen.js > build/docxgen.min.js # Optional

这篇关于使用javascript / jquery获取docx文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆