你好,下面是一个使用 Python 将 Word 文档转换为 PDF 的示例代码:
from comtypes.client import CreateObject
# 创建 Word 应用程序对象
word = CreateObject("Word.Application")
# 获取需要转换的 Word 文档对象
doc = word.Documents.Open("C:\\path\\to\\document.docx")
# 设置 PDF 输出路径
output_file = "C:\\path\\to\\output.pdf"
# 使用 SaveAs 方