16

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.

1
  • Maybe like code.google.com/p/jspdf. Maybe you can use the same approach. Commented Aug 27, 2012 at 15:00

1 Answer 1

9

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.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks any tips for what createPowerpointFromJSON would look like?
@dublintech I'm afraid I don't. I imagine that the Powerpoint standard is huge and complex, and there are probably no JavaScript libraries for Powerpoint document creation. If you are willing to use PDF instead of Powerpoint, [jspdf]( code.google.com/p/jspdf) is a library for creating PDF documents in JS.
yeah that seems to be a consensus. So I don't think anyone will beat your answer so I'll mark it as answered. Thanks.
This definitely works creating a ppt file but say if I already have a ppt file in xml format, can I prompt the user to download that xml and set the mime type to power point so that power point can open what it had originally saved as XML?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.