On “ondrop” event convert word document to text or string using javascript

三世轮回 提交于 2019-12-12 05:09:48

问题


i was trying to send word document from one user to another using peer.js it is fine working with text file (.txt, text/plain) where ever on word document i'm not getting content.

here is what i did till now

box.on('drop', function (e) {
            e.originalEvent.preventDefault();
            var file = e.originalEvent.dataTransfer.files[0];
            eachActiveConnection(function (c, $c) {
                if (c.label === 'file') {
                    if (file.type == "text/plain") {
                        alert("type : " + file.type + " - sendable");
                        c.send(file);
                    } else {
                        //here i need to convert word document into text/plain or atleast to string and send the file by using // c.send(file)

                    }

回答1:


I'm not an expert, but AFAIK docx documents follow a standard which is not simple plain text (as RTF is). I'd give a chance to DOCX.js, which promises to transform docx base64 strings back and forth to HTML.



来源:https://stackoverflow.com/questions/31181381/on-ondrop-event-convert-word-document-to-text-or-string-using-javascript

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