JavaScript cannot create files locally on the clients filesystem. However, I am wondering, if it is possible to somehow create a Powerpoint MIME in a web page (a div or a iframe) from some JSON and then let the UserAgent figure out it is Powerpoint in the expectation that the UserAgent will offer the user the choice to display it as a powerpoint presentation?
Note: The idea here is to be able to take some JSON and make a powerpoint presentation without having to make a request to a Server to create a Powerpoint file.
A PowerPoint add-in interacts with objects in PowerPoint by using the Office JavaScript API, which includes two JavaScript object models: PowerPoint JavaScript API: The PowerPoint JavaScript API provides strongly-typed objects that you can use to access objects in PowerPoint.
HTML files are objects supported in PowerPoint, so you can use the "Insert object" function to link to a web page document on your hard drive. Run Microsoft PowerPoint and open the presentation to which you want to add the HTML object.
One JavaScript library that can generate Powerpoint binary files is PptxGenJS.
Genreally speaking, you can create a link with a data URL that has a Powerpoint MIME type:
data:ms-powerpoint;base64,aGVsbG8gd... // base64-encoded file
Run your logic to create a binary Powerpoint file, then base64-encode it (e.g. with btoa
), and then dynamically generate a link or redirect window.location
to the data URI.
var binaryPPFile = createPowerpointFromJSON(sourceJSON);
window.location = "data:ms-powerpoint;base64," + btoa(binaryPPFile);
My hypothetical createPowerpointFromJSON
function might make calls to the PptxGenJS API, or any other Powerpoint-generating API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With