Cover image for Convert powerpoint to image

Convert powerpoint to image

antoinega profile image Antoine ・2 min read

Photo by Evgeni Tcherkasski on Unsplash

My team desires to process powerpoint files in order to manipulate content and create an image.

Spoiler: We used Aspose Slides at the end to do it.

Puppeteer + Office plugin

My first though was to use the Chrome plugin for Office, to open the Powerpoint file. In order to manipulate it, i though to use Selemenium or Puppeteer. I tried PuppeteerSharp to ease the process. It worked very easily. But Chrome does not allow plugin to be loaded while automated. So, even using the plugin unzipped, the browser cant use this plugin properly.

Powerpoint + Interop

I was thinking to use Office on a Windows VM or Docker. Then i found this post explaining how to install Office. But, the license can't allow this usage.
By curiosity, i tried to follow the post and ended with the following Dockerfile:

FROM mcr.microsoft.com/windows:1903
#USER ContainerAdministrator
ENV chocolateyUseWindowsCompression=false
RUN echo chocolatey.org >> "C:\Windows\System32\drivers\etc\hosts"
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" && \
    choco config set cachelocation C:\chococache

RUN choco install dotnetfx -y

RUN choco install microsoft-office-deployment --params="'/DisableUpdate:TRUE /Product:PowerPointRetail'" -y

RUN mkdir C:\\Windows\\SysWOW64\\config\\systemprofile\\Desktop
RUN powershell -Command new-object -comobject powerpoint.application

# Copy the c# App which uses Interop to save the ppt as a picture
COPY ./bin/Debug/net472/ .

VOLUME C:\\data

The license issue forces us to find another solution.

Aspose Slides

We found with this product. It can simply be used inside an Azure Function, without any customization. Why do we always want to find a difficult solution when there is a simple on available ?

The code is even available on their site.

Hope this help !

Posted on by:

antoinega profile



mainly .Net but looking for great stuff about anything


markdown guide