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
670 stars 96 forks source link

file download link and window.print() doesn't work in Officejs addin for Mac. #3385

Open sajaadkhan7 opened 1 year ago

sajaadkhan7 commented 1 year ago

File download and even window.print() does n't work in office js addin for Mac. Same code works for windows.

Environment

Expected behavior

When clicking on download link the file should be downloaded. but link click does nothing at all.

Current behavior

When I click on the link it does nothing at all. No popup and no console error at all.

Steps to reproduce

  1. setup word addin and add button.
  2. Upon clicking of the button following code should run : I m using word office js add-in on Mac. File download link is not working for me. I am getting no console errors at all. It just does nothing. I m using following code..
    
    const handleLinkClick = () => {
    var blob = new Blob([fileContent], {
      type: "application/octet-stream",
    });
    var link = document.createElement("a");
    link.href = URL.createObjectURL(blob);
    link.download = pdfFile?.name ? pdfFile.name.replace(/\.pdf$/i, ".docx") : "";
    link.click();
    };

I m getting the file content from the server. you can create the download link for any file.
Same code works perfectly for windows version.

## Link to live example(s)
I m using word office js add-in on Mac. File download link is not working for me. I am getting no console errors at all. It just does nothing.
I m using following code..

const handleOpenFile = () => {
    var blob = new Blob([fileContent], {
      type: "application/octet-stream",
    });
    var link = document.createElement("a");
    link.href = URL.createObjectURL(blob);
    link.download = pdfFile?.name ? pdfFile.name.replace(/\.pdf$/i, ".docx") : "";
    link.click();
  };
Same code works perfectly for windows version.

Secondly..
window.print() also doesn't work in the addin. No console errors at all.

## Context
This fix is really very important, as this issue is blocking the major release.

## Useful logs
There are no console errors at all.
sajaadkhan7 commented 1 year ago

any update?

sajaadkhan7 commented 1 year ago

is anybody looking into it?

sajaadkhan7 commented 1 year ago

??

sajaadkhan7 commented 1 year ago

Hi @jipyua please let me know the progress on this item.

JinghuiMS commented 1 year ago

@Rick-Kirkham Do you have any insights for this issue? Thanks!

sajaadkhan7 commented 1 year ago

I m not sure but looks like .. When we download or print in normal browser , in order to do that we need a popup box to respond to.

But in case of Safari web view, which our task pane addin uses, is blocking the popups from the addin.

sajaadkhan7 commented 1 year ago

Hi ... any progress?

wbecker commented 10 months ago

I am noticing the same problem. When I point Safari to the same word taskpane, I can download it (after it asks me for permission) but it seems to get blocked in the addin (Maybe because its asking for permission but doesn't have the ability to show the popup).

Our tool generates a report based on the document that you are viewing and allows the user to download this report. We could redirect them to a browser page to get the report when in Word on Mac but would be better if we did not have to!

sajaadkhan7 commented 10 months ago

I am noticing the same problem. When I point Safari to the same word taskpane, I can download it (after it asks me for permission) but it seems to get blocked in the addin (Maybe because its asking for permission but doesn't have the ability to show the popup).

Our tool generates a report based on the document that you are viewing and allows the user to download this report. We could redirect them to a browser page to get the report when in Word on Mac but would be better if we did not have to!

How did u do that.. I tried to redirect but I have had issues. So I have a BLOB from the backend now. how can I redirect that with the url?

image

wbecker commented 10 months ago

Our workaround doesn't redirect and auto download the pdf - it lets them click a button on the second page where the download does work!

On Thu, Nov 16, 2023 at 3:34 PM sajaad khan @.***> wrote:

I am noticing the same problem. When I point Safari to the same word taskpane, I can download it (after it asks me for permission) but it seems to get blocked in the addin (Maybe because its asking for permission but doesn't have the ability to show the popup).

Our tool generates a report based on the document that you are viewing and allows the user to download this report. We could redirect them to a browser page to get the report when in Word on Mac but would be better if we did not have to!

How did u do that.. I tried to redirect but I have had issues. So I have a BLOB from the backend now. how can I redirect that with the url?

[image: image] https://user-images.githubusercontent.com/37328086/283507013-358bfb74-3e9c-4e0a-80d8-af0090b5dff8.png

— Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-js/issues/3385#issuecomment-1814694906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACU7DBCOTHR26FWKLHQZNLYEYW7RAVCNFSM6AAAAAAYNYXWLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJUGY4TIOJQGY . You are receiving this because you commented.Message ID: @.***>