JavaScript库可读取客户端上的doc和docx [英] JavaScript library to read doc and docx on client
问题描述
我正在搜索一个JavaScript库,该库可以读取.doc
-和.docx
-文件.重点仅放在文本内容上.我对MS-Word文件中的图片,公式或其他特殊结构不感兴趣.
I am searching for a JavaScript library, which can read .doc
- and .docx
- files. The focus is only on the text content. I am not interested in pictures, formulas or other special structures in MS-Word file.
如果该库可与JavaScript FileReader一起使用,如下面的代码所示,那就太好了.
It would be great if the library works with to JavaScript FileReader as shown in the code below.
function readExcel(currfile) {
var reader = new FileReader();
reader.onload = (function (_file) {
return function (e) {
//here should the magic happen
};
})(currfile);
reader.onabort = function (e) {
alert('File read canceled');
};
reader.readAsBinaryString(currfile);
}
我通过互联网进行搜索,但找不到所需的内容.
I searched through the internet, but I could not get what I was looking for.
推荐答案
您可以为此使用docxtemplater(即使通常将其用于模板,也可以仅获取文档的文本):
You can use docxtemplater for this (even if normally, it is used for templating, it can also just get the text of the document) :
var zip = new JSZip(content);
var doc=new Docxtemplater().loadZip(zip)
var text= doc.getFullText();
console.log(text);
有关安装信息,请参见文档(我是该项目的维护者)
See the Doc for installation information (I'm the maintainer of this project)
但是,它仅处理docx,而不处理doc
However, it only handles docx, not doc
这篇关于JavaScript库可读取客户端上的doc和docx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!