Using PowerPoint as a WYSIWIG Editor for HTML Templates (Proof of Concept in C#)

The digital signage software that I develop for the local basketball club now supports HTML templates. I use this feature, e.g., for the introduction of the players on the video screens in the arena. For each player, I just enter the player’s data like name, jersey number, position, weight and height – which is then inserted dynamically into the template.

The software also supports importing PowerPoint slides as static images. PowerPoint plays an important role for many screens used at the home game, not least as it is one of the easiest ways for non-technical people without a design background to create content. And even though I feel very comfortable using Photoshop or Illustrator – if I quickly need to create a screen during the most stressful phase of home game, PowerPoint is my tool of choice.

One day, when I hand-coded a particularly simple HTML template for announcing the number of spectators, I spent a lot of time positioning the number next to a sponsor’s logo. That got me thinking: What if I could create templates like this in PowerPoint? All it would take would be some kind of marker text (e.g. {{Number}}) and a way to translate a PowerPoint slide to HTML.

What about PowerPoint?

Unfortunately, Microsoft removed the feature to export slides as HTML years ago. Third-party solutions do exist, but for my purposes, the libraries are prohibitively expensive. So, I had to find my own solution.

As a single developer, on a limited (time) budget, the first thing to do in such a case is to decide which problems not to solve:

  • I do not need to take care of different screen sizes; the width and height of the target display is fixed.
  • The HTML is not intended to be edited later, i.e., it does not have to be “pretty”. This means that div tags with absolute positions are fine.

In fact, I do not even need a full-blown PowerPoint to HTML conversion. I can “fake” the HTML conversion by

  • creating a PNG image of everything on the slide except the dynamic parts, and
  • translate the shapes containing dynamic texts into div tags that are styled to match the shape style on the slide.

For reading and analyzing the PowerPoint file, I use the (COM-based) Office automation API instead of the more modern Open XML SDK, because the API also allows me to create PNG files from the slides.

The code

I have published some proof-of-concept code on https://github.com/RWeigelt/PowerPointSlideHtmlLayoutDemo, written in C#/.NET 6.

The project includes the PowerPoint file Example.pptx that contains various markers for insertion points inside

  • normal shapes,
  • grouped shapes,
  • placeholder shapes (i.e., the editable shapes placed on the slide master), and
  • table cells.



When you run the project, it creates two files in your “Pictures” folder, HtmlPage.html and Background.png.

HTMLPage.html

The HTML file contains the insertion point shapes, translated to div tags:

(shown without background image, border added for illustration only)

Background.png

The background image contains all content that is not an insertion point (e.g., images, static texts).


Combined

When you open HtmlPage.html in a web browser, its CSS loads Background.png as a background image.

The result looks like this:


Where to go from here

This demo code is obviously just a start. While it does consider fonts, texts sizes and styles as well as alignment, it does not cover all design and layout capabilities.

Depending on your requirements, you may want to look into supporting text effects (e.g., shadow or glow should be possible in CSS) and transformations like shape rotation. You also may choose a different syntax for the insertion points.

The code is licensed under the “BSD Zero Clause License”, so you can use it without limitations and do not even have to credit me. I do not have plans to develop this into a general-purpose library; further development will be very specific to the needs of my digital signage software. If you take this idea and create something from it that may be of interest to others, drop me a line and I will link to your website or GitHub repository.

2 Comments

Comments have been disabled for this content.