Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I render a Word document (.doc, .docx) in the HTML using angular

I have successfully done code to display a PDF file in HTML using angular instead of the "Open/Save" dialog. Now, I'm stuck trying to display a Word document. I used to display a Word document and done successfully but i want to restrict the file to be opened in new tab so that he can't download

like image 1000
Vedha Avatar asked Sep 05 '26 10:09

Vedha


1 Answers

Unlike PDF, Word documents can't be opened directly in the browser, but if you want to display a word document in a web page and secure it (prevent users from downloading it) you can use Either Google Docs/Office 360 Viewer

Embed them a new page and write some JS to further secure it by disabling copy/paste & right-click (but please note that this JS might get disabled) using Iframe like this

<iframe src="https://docs.google.com/gview?url=http://ieee802.org/secmail/docIZSEwEqHFr.doc&embedded=true" frameborder="0">
</iframe>

Examples:

Google Docs Viewer

Microsoft Office Viewer

like image 91
Anas AL-zghoul Avatar answered Sep 06 '26 23:09

Anas AL-zghoul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!