I have a .doc type attachment , Attachment contains some images and text . I want to show all content of this attachment on vf page. I am able to show pdf, images type attachment preview on vf page , issue is only with (.doc, docx, .ppt ) file. it downloads the attachment instead of showing in new tab.

If attachment is 'attach' which is document file and it may contain images and text. If I convert body to string like this and show string on vf page in outputtext string attachbody = attach.body.tostring(); I am getting error not UTF-8 type string,

if I use this code show string on vf page in outputtext string attachbody = base64Encode(attach.body); I am getting exceed 135 kb error

Your help would be appriciated. Please suggest me sample code. OR javascript jquery code if required.


1 Answer 1


This is really down to the browser capability rather than Visualforce. If you use the same syntax for a .doc as you do for a .pdf, the browser will display a preview if there is a plugin that supports the format. If there is no plugin configured, the browser will simply download the file for you to open with the executable of your choice.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .