Skip to content

PowerPoint file writer

The goal of this module is to take our Presentation data structure and turn it into a PowerPoint file.
This is mainly used when users wants to download their presentation.

Thankfully, in this case we were able to rely on a library that does most of the work when producing the .pptx file: PptxGenJS.
Unfortunately, this is not perfect either, and we quickly hit its limitations when trying to support as many features as possible.

So we ended up forking the library into this internal repository, where we implemented the missing features.
The downside is that the library’s code quality was quite poor, so we had to work with it while trying not to change it too much, in case we want to integrate external updates at some point.
We also considered rewriting a proper .pptx writer from scratch, given how painful it was to extend this one, but so far the need has not been strong enough.

Bottom line: the main complexity of .pptx writing resides more in this repository than in our main monorepo.
And the complexity points are very similar to the ones we handle in the file parser (since it’s the other side of the same process).

Here are the main steps we take when writing the .pptx file:

  • receive our Presentation data structure as input
  • download all images from it to the file system (to simplify the rest of the process)
  • use the writing library to create the presentation
  • loop over slides
    • use the writing library to create the slide
    • loop over shapes
      • transform the shape into the writing library’s expected input data structure (less straightforward than ours)
      • use the writing library to create the shape
  • use the writing library to write the file