leora
leora

Reputation: 196539

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.

Upvotes: 8

Views: 8424

Answers (2)

Mihnea DB
Mihnea DB

Reputation: 396

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.

Upvotes: 2

scanny
scanny

Reputation: 28903

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 :)

Upvotes: 12

Related Questions