简体   繁体   中英

How to convert DOCX to ODT format using javascript?

I am working on a in-website document editor(word and excel document). So far I am able to edit ODT files using WEBODF . Is there any way to convert DOCX file to ODT using javascript so that i can use the file in the editor? any alternatives for editing word and excel documents inside a website? I have tried saving the file in OneDrive and then using the share link to open editing on sharepoint but this editor cannot be inserted inside an website and can only be done in a new tab? i need the editor inside the website as i need to implement azure versioning of the documents

WebODF is an awesome tool to be used as an online editor. Assuming you have no restrictions implementing a separate backend server, you can use libreoffice, which gives you a command line utility to exactly perform that job. You can convert docx file to odt file using the following command -

soffice --headless --convert-to odt <input file>.docx

The approach would be to create an API

  • Which would take docx file as input
  • Store that file temporarily somewhere and run the above command
  • Serve the converted odt file and delete the temporary files. If you want to store those files in the server, then you can maintain a database to achieve that as well.

To take care of restricted cross origin policy, you can implement AJAX calls in the front-end to perform file uploading and viewing operations using Javascript blobs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM