• DBA2012
  • 0 Points
  • Member since 2012

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1
I am having a word document stored in Document object. I need to retrieve only the content and display it in a VF page.

I have written the query in a controller class to get the body of the document. The body is returning as Blob data type. Then I am converting the Blob to String using ToString() method in Apex.

Code for your reference:
Document d = [Select body, bodyLength, ContentType, Url from Document where id = :'01580000000n17L'];
Blob b = d.body;
String s = b.toString();

But the output is showing as more encoded characters along with the content. These encoded characters, I suppose, are meta-data for the word document like font properties, alignment, etc. I need only the content of the document.

In the same way, if I use a Notepad file to get the content, it is working fine and I get only the content.

Please tell me a way to get the content only from a Word document without the encoded characters.