Convert PPT to PNG via python

I want to convert PPT to png or other image formats using Python.

This question was asked on SO, but essentially recommends running OpenOffice on a headless X server, which was an absolute pain the last time I used it. (Mostly due to the difficulty of replicating errors due to OO failure.)

Is there any other way, (I hope only Linux CLI utilities and pure Python above them?)

+4
source share
1 answer

The main workflow:

  • convert ppt to pdf using a PDF printer from PowerPoint or OpenOffice built into the PDF converter

  • use ghostscript to convert PDF to png or another image format (something along the line gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r100 -sOutputFile=out.png in.pdf )

You can use Python to script this (and the OOo / MSPP pilot using Uno / COM) or whatever script you want.

As far as I know, the Python library does not process PPT files or convert PDF files to PNG.

As for handling OOo alarm messages, I would catch the Exceptions and try to restart OOo when such an event occurs (and probably skip the file by adding it to the list of suspicious files requiring manual processing).

You can find this article http://www.linuxjournal.com/node/1007788 interesting because it provides a class that uses an existing OOo instance to connect to or runs one if required in a transparent way. It comes with an example xls → csv conversion ( http://www.linuxjournal.com/content/convert-spreadsheets-csv-files-python-and-pyuno ), which can be used as the basis for the conversion you want to try,

+2
source

Source: https://habr.com/ru/post/1304084/


All Articles