Murali Kris

Murali Kris

  • 1.5k
  • 254
  • 48.4k

How to Read Content from Ms word

Jan 7 2019 1:34 AM
Hi All,
 
As per requirement as of now i can read content(text) from .txt file using java script.yes i can format text after reading, here text is fixed formating using script, working fine now.
 
To make dynamic changes User want to read Ms word file but user/client want read content from MS word. Since ms word is allows text formatting. they will make some changes like alignment, font size, font-family etc..
 
as usally i replaced ms word file to read, displaying content some wrong character symbols.
 
Reading .txt file using java script. as expected output is below.
 
Google LLC is an American multinational technology company that specializes in Internet-related services
 
Same text from word. But reading MS word file using JavaScript. output is below.
 
PK?!NU"""x("[Content_Types].xml ""("""KN"@ """%"!"""B%"`;"8""C3Ngc"""NB
 
how to read text from Ms word.
 
Kindly help me here.
 
This is the script i am using to read content.
 
<script src="/jquery-3.3.1.min.js"></script>
<script>
window.onload = function () {
getFile()
}
function getFile() {
debugger;
var fileTobeRead = "/Document.docx";
$.ajax({
type: "GET",
url: fileTobeRead,
dataType: "text",
success: function (data)
{
$('#divFileData').html(data)
},
error: function (request, status, error)
{
alert(error);
}
});
}</script>

Answers (2)