Home » Javascript » Button click launch MS Word – Javascript

Button click launch MS Word – Javascript

Posted by: admin August 19, 2018 Leave a comment


I have an API that downloads the file (Array buffer) from S3 storage and using following code to download the file

//Res is the array buffer from S3
import FileSaver from 'file-saver';
var b = new Buffer(res.text, 'base64');

var blob = new Blob([b], { type: "application/octet-stream" });
FileSaver.saveAs(blob, fileName);

Instead of downloading it on local, I want to open the file (PDF, Doc) in a users local MS Word directly when user clicks the button.

I tried looking into the Stackoverflow post

Launch MS Word on Client PC to Edit Document on Server

But this is not clear enough so I am posting this again.

If anyone has any idea that I can tweak with to open MS Word on click from Web app that would be really helpful

type: "application/octet-stream"