Create Powerpoint with JavaScript

后端 未结 1 1781
遥遥无期
遥遥无期 2021-02-13 22:19

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

1条回答
  •  广开言路
    2021-02-13 22:46

    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 讨论(0)
提交回复
热议问题