Open a document from a template in SharePoint through Word JavaScript in a task pane

Open a document from a template in SharePoint through Word JavaScript in a task pane
5

Upvotes

Upvote

 Aug 01 2023
0 Comments 
New

I am trying to open a SharePoint template as a document through a Word task pane using Word JavaScript. I am able to access the "downloadUrl" and "webUrl" properties of the file through the site's drive item collection using Graph API. I need to convert this URL into an object and convert it into a base64 string to pass to "context.application.createDocument(base64Document)" method. I am able to create the base64 string and open a document when using the HTMLInputElement "file" object. Searches refer to the "file" object as a type of Blob but this doesn't help in getting an equivalent object from the URL. I need to call SharePoint through the Graph API, get a drive item, and open the template as a file through Word JavaScript in the task pane. See #3512