5

我在这里玩了一轮 python-pptx,但我还需要另存为 pdf,我似乎没有看到这个库支持这个功能。

是否有人建议(在此库中或外部解决方案中)创建 pptx 文件,但也可以选择另存为 pdf。

4

2 回答 2

5

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

于 2014-10-18T05:57:16.560 回答
1

我已经成功使用unoconv。但是,它并不完美 - 它使用 LibreOffice 来呈现您的文件,因此看起来可能与预期不同。

于 2016-10-19T12:55:32.587 回答