最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Create Powerpoint with JavaScript - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question asked Aug 27, 2012 at 14:49 dublintechdublintech 17.8k31 gold badges88 silver badges118 bronze badges 1
  • Maybe like code.google./p/jspdf. Maybe you can use the same approach. – Prusse Commented Aug 27, 2012 at 15:00
Add a ment  | 

1 Answer 1

Reset to default 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.

发布评论

评论列表(0)

  1. 暂无评论