ApryseSDK / webviewer-react-sample

Sample to demonstrate integrating WebViewer into React
Other
172 stars 99 forks source link

Webviewer is not loading when distribution X-Frame-Options set to DENY #32

Closed sadashiv-sumasoft closed 9 months ago

sadashiv-sumasoft commented 9 months ago

Hi,

I am using the PDFTron webviewer to show the document as well as the PPTX in my React applications. Our application is hosted on AWS and delivered through CloudFront. We have the cloudfront response headers policy enabled for security reasons, and that policy has X-Frame-Options set to DENY, which we cannot set to "SAMEORIGIN". and that X-Frame-Options stopping our webviewer from getting loads.

Could you please suggest some solutions for the above problem? Thank you in advance.

WebViewerNotLoading

mparizeau-pdftron commented 9 months ago

Hi, this is likely because WebViewer creates an iframe element which is where the content is being blocked from when you use those options. We have a relatively new option to load WebViewer as a Web Component. You can read more about it here https://docs.apryse.com/documentation/web/guides/web-component-vs-iframe#webviewer-as-a-web-component

The quick summary is that instead of WebViewer({ ... }) you do this WebViewer.WebComponent({ ... })

sadashiv-sumasoft commented 9 months ago

Yes, I can see that the recent release has a WebComponent feature. I implemented that in my code, and it works for me.

I feel there are issues while unmounting that web component. When we go to the previous page from the web component page, our whole website is getting re-loaded.

  WebViewer.WebComponent(
      {
        path: "/webviewer/lib",
        fullAPI: true, //This is added to create the flattened pdf
        initialDoc: fileInfo.cdnUrl,
      },
      viewer.current
    ).then((instance) => {
    //my own custom logic
    })
mparizeau-pdftron commented 9 months ago

Since this sounds a bit more complicated and may not be related to the react sample can you please submit a ticket here https://support.apryse.com/support/tickets/new

sadashiv-sumasoft commented 9 months ago

Thanks for your advice, @mparizeau-pdftron! I will create one support ticket for the above issue.