none
Office js API-Task pane app-download file from web RRS feed

  • Question

  • I'm a developer working on an Office JS task pane app in Word. Using the contents of the user's file my app generates a document as a pdf either a docx on my application's server. I would like to give the user the option to download this generated file directly from the task pane. I have tried to implement this using Javascript (linking to the document with window.location.href) but the behavior I have seen has been inconsistent across platforms and does not function well anywhere. 

    On the Mac the pdf is downloaded and opened, but it takes the place of the application in the task pane and there is no way to save the pdf permanently. On the iPad trying to download the document within the pane crashes the add in. On Word 2016 nothing happens when the link is clicked (but I have confirmed that the server is sending a response).

    While it is possible to open the link to the document in a browser (using something like window.open) my application requires the user to sign in for permissions to download. While the users are signed in within the task pane, but they are not signed in on the browser. I would really like to avoid asking users to sign in again in the browser. 

    Is there a way to start a document download within an Office add-in task pane without bouncing the user to a seperate browser? 

    Tuesday, July 12, 2016 5:22 PM

Answers

  • >>>Does such functionality exist? ?

    According to your description, JavaScript API for Office does not exist such functionality. I also create Office Add-in Task Pane with ASP.Net and try to use a Generic Handler to download files, unfortunately, I am fail. So I suggest that you could submit any feedback to OfficeDev UserVoice:

    https://officespdev.uservoice.com/

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Tuesday, August 2, 2016 2:54 PM
    • Marked as answer by David_JunFeng Tuesday, August 2, 2016 2:55 PM
    Monday, July 25, 2016 7:49 AM

All replies

  • >>>Is there a way to start a document download within an Office add-in task pane without bouncing the user to a seperate browser? 

    According to your description, I have made a sample to try to find solution to overcome this issue, unfortunately, I am not able. I will still keep troubleshooting this issue but it will take some time. 

    In addition you could submit any feedback to OfficeDev UserVoice:

    https://officespdev.uservoice.com/

    Thanks for your understanding.
    Wednesday, July 13, 2016 9:51 AM
  • Thank you for taking the time to try creating a sample. I will submit some feedback through UserVoice as you suggest. 
    Wednesday, July 13, 2016 1:35 PM
  • Hi BenjaminRichardson,

    The JavaScript API for Office provide Document.getFileAsync method to receive the Word document as a byte array or retrieve the text of the Word document as a string. Then you can call WCF Service to save Word document on client computer.

    For more information, click here to refer about How to save Word document from task pane app

    Saturday, July 16, 2016 5:44 AM
  • Thank you for your help, this is exactly what I was looking for. Do you know if the method you used will work across all platforms (Mac, iOS)?

    Edit:

    David, thank you for the link. On closer inspection I am under the impression that the sample you provided saves a copy of the file on the server. This I am already able to do successfully. It is specifying the download location of a file on the client's machine that I am trying to find a solution to.

    Monday, July 18, 2016 1:11 PM
  • >>>Do you know if the method you used will work across all platforms (Mac, iOS)?

    Firstly we are glad to hear that you have great progress, Document.getFileAsync method supports Office for iPad.

    For more information, click here to refer about Document.getFileAsync method

    Tuesday, July 19, 2016 9:01 AM
  • Thank you for your reply. I am aware of the platform capabilities of office.js library. I am already able to upload a file on all of these platforms. 

    My problem is this: I have a file on my server. I want to allow the user to download that file from within the task pane app. Does such functionality exist? 


    Tuesday, July 19, 2016 1:22 PM
  • >>>Does such functionality exist? ?

    According to your description, JavaScript API for Office does not exist such functionality. I also create Office Add-in Task Pane with ASP.Net and try to use a Generic Handler to download files, unfortunately, I am fail. So I suggest that you could submit any feedback to OfficeDev UserVoice:

    https://officespdev.uservoice.com/

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Tuesday, August 2, 2016 2:54 PM
    • Marked as answer by David_JunFeng Tuesday, August 2, 2016 2:55 PM
    Monday, July 25, 2016 7:49 AM