I tried different methods like iframe ,object to view/show the document on web page as a preview.Iframme with google doc only worked for publicaly available document.How can I display/preview document stored on my localhost folder.
Asked
Active
Viewed 2,515 times
0
-
iframe should work. Not sure what you mean that it only works for "publicly available documents", it seems like it should be obvious that you can only iframe documents that you have access to – WilliamNHarvey May 22 '18 at 19:56
-
Look at this https://stackoverflow.com/questions/27957766/how-do-i-render-a-word-document-doc-docx-in-the-browser-using-javascript – Emeeus May 22 '18 at 22:34
-
Tried that but the host should be exposed to outside.any other options other than using google doc or microsoft view? – AKR May 23 '18 at 12:27
1 Answers
3
You can use iframe tag of html as following:
const YOUR_URL = https://calibre-ebook.com/downloads/demos/demo.docx;
<iframe
className="doc"
src={`https://docs.google.com/gview?url=${YOUR_URL}&embedded=true`}
/>

Sania Khushbakht Jamil
- 812
- 6
- 16