为什么将 pptx 保存为 pdf 会导致空白页面?

发布于 2025-01-11 22:04:58 字数 347 浏览 1 评论 0原文

powerpoint = win32com.client.Dispatch('PowerPoint.Application')
powerpoint.Visible = True
pdf = powerpoint.Presentation.Open("test2.pptx")
pdf.SaveAs("test2", FileFormat = 32)
pdf.Close()
powerpoint.Quit()

我正在尝试使用此代码将 pptx 转换为 PDF。 “test2.pptx”位于同一文件夹中,它不是一个空的演示文稿。我认为 .Open 行有问题,因为当我运行代码时,它会打开一个空演示文稿。

powerpoint = win32com.client.Dispatch('PowerPoint.Application')
powerpoint.Visible = True
pdf = powerpoint.Presentation.Open("test2.pptx")
pdf.SaveAs("test2", FileFormat = 32)
pdf.Close()
powerpoint.Quit()

I'm trying to use this code, to convert a pptx to PDF. The "test2.pptx" is in the same folder and it's not an empty presentation. I think something wrong with the .Open line because when I run the code it opens an empty presentation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偷得浮生 2025-01-18 22:04:58

我已经成功解决了这个问题,这是它的工作代码:

import win32com.client
import os

x = os.path.realpath("test2.pptx")
y = os.getcwd() + "\\test02.pdf"

powerpoint = win32com.client.gencache.EnsureDispatch('PowerPoint.Application')
powerpoint.Visible = True
pdf = powerpoint.Presentations.Open(x)
pdf.SaveAs(y, FileFormat = 32)
pdf.Close()
powerpoint.Quit()

I've managed to solve the problem, here is the working code for it:

import win32com.client
import os

x = os.path.realpath("test2.pptx")
y = os.getcwd() + "\\test02.pdf"

powerpoint = win32com.client.gencache.EnsureDispatch('PowerPoint.Application')
powerpoint.Visible = True
pdf = powerpoint.Presentations.Open(x)
pdf.SaveAs(y, FileFormat = 32)
pdf.Close()
powerpoint.Quit()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文