Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 983
Hari Avatar asked Feb 06 '23 13:02

Hari


1 Answers

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

like image 91
bren Avatar answered Feb 23 '23 04:02

bren