简体   繁体   English

如何使用 javascript 将 DOCX 转换为 ODT 格式?

[英]How to convert DOCX to ODT format using javascript?

I am working on a in-website document editor(word and excel document).我正在开发网站内文档编辑器(word 和 excel 文档)。 So far I am able to edit ODT files using WEBODF .到目前为止,我能够使用WEBODF编辑 ODT 文件。 Is there any way to convert DOCX file to ODT using javascript so that i can use the file in the editor?有什么方法可以使用 javascript 将 DOCX 文件转换为 ODT,以便我可以在编辑器中使用该文件? any alternatives for editing word and excel documents inside a website?在网站内编辑 word 和 excel 文档的任何替代方法? 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?我曾尝试将文件保存在 OneDrive 中,然后使用共享链接在 sharepoint 上打开编辑,但此编辑器无法插入网站内,只能在新选项卡中完成? i need the editor inside the website as i need to implement azure versioning of the documents我需要网站内的编辑器,因为我需要实现文档的 azure 版本控制

WebODF is an awesome tool to be used as an online editor. WebODF 是一个很棒的工具,可以用作在线编辑器。 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.假设您没有限制实施单独的后端服务器,您可以使用 libreoffice,它为您提供了一个命令行实用程序来准确执行该工作。 You can convert docx file to odt file using the following command -您可以使用以下命令将 docx 文件转换为 odt 文件 -

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

The approach would be to create an API该方法是创建一个 API

  • Which would take docx file as input哪个将 docx 文件作为输入
  • Store that file temporarily somewhere and run the above command将该文件临时存储在某处并运行上述命令
  • Serve the converted odt file and delete the temporary files.提供转换后的 odt 文件并删除临时文件。 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.为了处理受限的跨源策略,您可以在前端实现 AJAX 调用,以使用 Javascript blob 执行文件上传和查看操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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