admin管理员组

文章数量:1605300

之前用win32com模块转pdf,安装模块的过程中不太顺利,后面发现有docx2pdf模块,直接可以安装使用。

#在运行的过程中不能打开word文档,否则就会报错。

# coding=utf-8
# 20221026

from docx2pdf import convert
import glob ,os

#实现对当前路径下report文件夹下的所有word转pdf

path = os.path.join(os.getcwd(),'report')
files = glob.glob(os.path.join(path,'*.docx'))
for file in files:	
	inputFile = file
	filename = os.path.basename(file).replace('docx','pdf')
	outputFile = os.path.join(path,filename)
	file = open(outputFile, "w")
	file.close()
	convert(inputFile, outputFile)

本文标签: 批量PythonPDFword