In Sharepoint you can use <WebPartPages:AllowFraming runat="server" />
to disable the SAMEORIGIN for X-FRAME-OPTION giving you the opportunity to call your page from an iframe (see this other article).
However you cannot use the same trick to preview a file into the browser with WopiFrame.aspx
. But there is a way to do it, using the parameters into the URL.
Let’s say the url to preview your document is:
https://my.company.com/sharepoint/_layouts/15/WopiFrame.aspx?sourcedoc=/files/Demo.docx&action=default
You need to replace action=default
with action=embedview
, AND you need to call WopiFrame2.aspx
instead of WopiFrame.aspx
(which will lead to a Something Went Wrong - Sorry, you don't have access to this page
).
So the URL to use for your iframe will be:
https://my.company.com/sharepoint/_layouts/15/WopiFrame2.aspx?sourcedoc=/files/Demo.docx&action=embedview