Is it possible to convert doc/docx to html using jquery/javascript? [closed]

萝らか妹 提交于 2019-12-10 10:44:39

问题


I need to convert doc/docx to html. I have files stored in Amazon s3. I need to view & edit it in browser. Right now, I am using Apache POI to convert doc/docx to html. And I am displaying the response on HTML editor(Jquery Plugin). It works but alignment/format changes. Also images not extracted. Any solution to fix image extraction & formatting issues, please refer or refer any Jquery/JS plugin for conversion.


回答1:


Doing a quick Google Search, I found these libraries: (I have not used, nor endorsed any of these)

  • docx2html
  • mammoth

docx2html basic functionality:

var docx2html=require('docx2html')
docx2html(fileInput.files[0],{container:document.getElementById('a')}).then(function(html){
    html.toString()
})

mammoth basic functionality:

var mammoth = require("mammoth");


mammoth.convertToHtml({path: "path/to/document.docx"})
    .then(function(result){
        var html = result.value; // The generated HTML 
        var messages = result.messages; // Any messages, such as warnings during conversion 
    })
    .done();

I hope this was, at least, useful



来源:https://stackoverflow.com/questions/41121127/is-it-possible-to-convert-doc-docx-to-html-using-jquery-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!