OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
641 stars 92 forks source link

Excel Taskpane Add-in Iframe Unable to load blob URLs #4421

Open KaranLala opened 2 weeks ago

KaranLala commented 2 weeks ago

Provide required information needed to triage your issue

Unable to load a PDF in an embedded iframe in the taskpane when using a blob url created using URL.createObjectURL. PDFs hosted online work fine.

Your Environment

Expected behavior

The iframe should load the PDF

Current behavior

The iframe document does not load, it is set to about:blank. Opening the URL in a new tab renders the PDF correctly

Steps to reproduce

  1. Can use react pdf to create a blob or use the react pdf PDFviewer

Context

I am trying to create a Excel to PDF templating system. The user should be able to add content to an excel sheet and generate a PDF based on content on that page.

m-hellesen commented 1 week ago

Can you please provide a manifest or some source code to show what you are trying to do?

KaranLala commented 1 week ago

sure, here is a codesandbox: https://codesandbox.io/p/sandbox/react-pdf-sample-3tnwyh?file=%2Fsrc%2FApp.js%3A14%2C5

This codesandbox doesn't work properly on Chrome / Brave. It works fine on Firefox.

If you run the same code on your local machine it should work correctly. This is an example of something that I expected to work in an Excel taskpane. The PDFViewer component is just creating a blob and embedding it in an iframe with the help of URL.createObjectURL({blob})