2015-07-02 12 views
0

我試圖從一個用戶發送word文檔到另一個使用peer.js 它很好地處理文本文件(.txt,text/plain)永遠在word文檔我沒有得到內容。關於「ondrop」事件將word文檔轉換爲文本或使用javascript的字符串

這裏是我做了什麼至今

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) 

        } 
+0

請有人幫忙,我想獲得文件內的內容,即使它是word文檔 – Arjun

回答

0

我不是專家,但據我所知DOCX文檔遵循標準,是不是簡單的純文本(如RTF是)。我想給一個機會DOCX.js,它承諾將docx base64字符串來回轉換爲HTML。

+0

你有沒有任何示例代碼請問 – Arjun

+0

meh ...庫只是一個函數...'function convertContent(input) '... – Jack

+0

我試過, var text = convertContent(e.originalEvent.dataTransfer.files [0]); 它引發了一個錯誤convertcontent沒有定義 – Arjun