Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does python-pptx support saving a file as pdf?

I am playing around with python-pptx here but I need to also save as pdf and I don't seem to see that this library support this feature.

Does anyone have a suggestion (either within this library or an external solution) to create a pptx file but also have the option to save as pdf.

like image 390
leora Avatar asked Oct 14 '14 16:10

leora


2 Answers

python-pptx doesn't support saving as PDF and it's very unlikely it ever will. The reason is that saving as a PDF involves rendering the PowerPoint file (.pptx) and the focus of python-pptx is on reading and writing the .pptx file format.

The scope of developing a faithful rendering engine for PowerPoint is both large and almost completely orthogonal to the file read/write problem.

The main rendering engine for PowerPoint is, well, PowerPoint :) The (Microsoft) PowerPoint API is accessible via IronPython on a Windows machine that has PowerPoint installed. It's not suitable for everything, for example it's not a good solution for server-side work, but if your project is small scale and you're already running on Windows it can be a good solution. I use it myself in the development of python-pptx (I'm the main author) for certain types of testing.

There are other rendering libraries out there, but I don't know of any open source ones. The one I've seen is a pay-for-license package. I'm sure there must be others because applications like GitHub for Mac and Box have fairly good previewing capability. I can't imagine they wrote that from scratch :)

Sorry I didn't have better news for you :)

like image 167
scanny Avatar answered Sep 29 '22 15:09

scanny


I've had success using unoconv. However, it is not perfect - it uses LibreOffice to render your file, so things might look different than expected.

like image 44
Mihnea DB Avatar answered Sep 29 '22 16:09

Mihnea DB