我可以不吃啊 发表于 2022-8-9 14:44:28

Python 将 docx 转为 PDF

安装

pip install docx2pdf



使用

from docx2pdf import convert

# doc 文件 需要先转为 docx 文件(一般情况下、直接修改后缀名、不会对原文件有影响)
inputFile = '1.docx'# 要转换的文件:已存在
outputFile = '1.pdf'# 要生成的文件:不存在

# 先创建 不存在的 文件
f1 = open(outputFile, 'w')
f1.close()

# 再转换往PDF中写入内容
convert(inputFile, outputFile)
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: Python 将 docx 转为 PDF