使用 python-pptx 打印 Powerpoint 幻灯片 [英] Print Powerpoint slide with python-pptx

查看:77
本文介绍了使用 python-pptx 打印 Powerpoint 幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 python-pptx 来访问幻灯片(我发现它比使用 win32 流畅得多,因为它不需要打开 Powerpoint 窗口.但是,我已经检查了文档,但找不到任何方法打印幻灯片.我错过了什么吗?

I've been using python-pptx to access slides (I find it much smoother than using win32 as it doesn't need to open the Powerpoint window. However, I've checked the docs but can't find any method of printing a slide. Am I missing something?

这是我目前所拥有的:

from pptx import Presentation
prs = Presentation(path)
for slide in prs.slides:
    if slide.name == slide_I_want:
        #send slide to printer

推荐答案

python-pptx(故意)没有 PowerPoint 渲染器,因此无法打印幻灯片(将它们渲染到纸张/PDF).它也不能另存为 PDF、另存为 JPG 或执行任何其他需要渲染的操作(例如自动缩小文本以适应特定区域).

python-pptx (purposely) does not have a PowerPoint renderer, and so cannot print slides (render them to paper/PDF). It also can't save as PDF, save as JPG, or do anything else that requires rendering (such as automatically shrink text to fit into a particular region).

基本原理是范围和重点之一.渲染器本身就是一个复杂的软件,并且仅与(无头)PPTX 文件编辑器弱耦合,这就是 python-pptx .渲染器还与显示平台紧密耦合,这在 Python 中没有得到很好的支持,在 OS X、Linux 和 Windows 等各种操作系统上获取字体度量等内容,可能取决于显示器和/或打印机司机等

The rationale is basically one of scope and focus. A renderer is a complex piece of software all on its own, and is only weakly coupled to a (headless) PPTX file editor, which is what python-pptx is. A renderer also has tight coupling to the display platform, which is not well supported in Python, getting things like font-metrics and so forth over the various operating systems like OS X, Linux, and Windows, perhaps depending on display and/or printer drivers, etc.

这篇关于使用 python-pptx 打印 Powerpoint 幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆