How to convert a word document to odt Ionic 4

Hi, i am working on an Ionic 4 project. I am trying to convert a word document to a odt(OpenOffice) document. I searched which package can suit me. I found those two: https://www.npmjs.com/package/asciidoctor-converter-opendocument https://www.npmjs.com/package/cnx-designer-convert-odt

but they are not well documented. Then i found this: https://www.npmjs.com/package/simple-pandoc I am trying to implement the code: const pandoc = require(‘simple-pandoc’); const wordToOdt = pandoc(‘docx’, ‘odt’);

var fs=require(“fs”); wordToOdt(fs.readFileSync(‘assets/ICEVI News.docx’)).then(md => {

console.log(md.toString()); });

However , i am getting : fs.readFileSync is not a function I was wondering if you could help me ,please? Do you have maybe other suggestions/packages to achieve the desired functionality,please? Thank you in advance.

Sorry to be the bearer of bad news, but pandoc is going to present two rather huge hurdles for you:

  • not all npm packages work in browser environments. some of them assume they are running under node.js, and the fact that things are bombing on (lack of) fs indicates that this is one of them.
  • that JavaScript library is just a thin wrapper over the pandoc executable, which doesn’t seem to have either an Android or an iOS version, so you would have to port pandoc itself for mobile use. I would be surprised if that were a trivial operation - I would expect a program like that to have a zillion dependencies.

Maybe doing the document conversion itself in the cloud might be a more viable option than trying to do it on-device.