手记

使用Python转换PPT为PDF

使用Python转换PPT为PDF

1. 首先下载必要包

pip install comtypes
pip install pptxtopdf

2. 写代码

from pptxtopdf import convert

# 需要转换的文件目录
input_dir = r"./origin_files"
# 转换后的文件目录
output_dir = r"./conversion_files"

# convert依赖comtypes包,所以comtypes包一定要安装
convert(input_dir, output_dir)

3. 效果(转换有点慢,需要耐心等待,看不到进度)

执行转换完显示:

结果:


附录:也可使用命令行执行:

# --input_dir:需要转换的文件目录
# --output_dir:转换后的文件目录
pptxtopdf --input_dir .\daily_tools\pptx_to_pdf\origin_files\ --output_dir .\daily_tools\pptx_to_pdf\conversion_files\ 
0人推荐
随时随地看视频
慕课网APP