7

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.

scanny
  • 26,423
  • 5
  • 54
  • 80
leora
  • 188,729
  • 360
  • 878
  • 1,366
  • Python-pptx will only work in creating Powerpoint slides. You can use `PDFMiner` or `PyPDF2` for creating `PDF's`. Cant think of any module that does both – Beginner Oct 14 '14 at 16:11

2 Answers2

9

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

scanny
  • 26,423
  • 5
  • 54
  • 80
  • thanks. The reason I asked is that a few ppt export libraries in C# and java also support "save as pdf" like this one: http://www.aspose.com/.net/powerpoint-component.aspx – leora Oct 18 '14 at 12:30
1

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.

Mihnea DB
  • 386
  • 3
  • 9