【更新】项目重构了一下,支持字体颜色,字形,图片
最近遇到一个需求,需要将非常多内容的(文字/表格)word文档展示出来,这个需求出现在pc端就用插件好了或者直接下载文件?如果需求是在移动端呢?怎么办?转成html吧。。。几十页的word怎么搞?为了造福大家,花了几天时间撸了一个插件word-to-html,可以转嵌套的表格,合并单元格的表格,github地址.
word-to-html
feature
- images
- font-size color/style
- table
example
var path = require("path");
var Word2html = require("../src/index.js");
//Word document's absolute path
var absPath = path.join(__dirname, "test.docx");
const word2html = new Word2html(
absPath,
{
outputDir: path.resolve(__dirname, 'temp')
}
);
word2html.convert();
event
zipReady
- callback
<Function>
- zip
<admZip>
- zip
you can use zip
to get any resource you need, like images; adm-zip
var path = require("path");
var Word2html = require("../src/index.js");
//Word document's absolute path
var absPath = path.join(__dirname, "test.docx");
const word2html = new Word2html(
absPath,
{
outputDir: path.resolve(__dirname, 'temp')
}
);
word2html('zipReady', (zip) => {
zip.getEntries();
});
word2html.convert();