#-*- coding:utf-8 -*-
importosfrom win32com.client importDispatch, constants, gencache, DispatchExclassPDFConverter:def __init__(self, pathname, export='.'):
self._handle_postfix= ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']
self._filename_list=list()
self._export_folder= os.path.join(os.path.abspath('.'), 'pdfconver')if notos.path.exists(self._export_folder):
os.mkdir(self._export_folder)
self._enumerate_filename(pathname)def_enumerate_filename(self, pathname):'''读取所有文件名'''full_pathname=os.path.abspath(pathname)ifos.path.isfile(full_pathname):ifself._is_legal_postfix(full_pathname):
self._filename_list.append(full_pathname)else:raise TypeError('文件 {} 后缀名不合法!仅支持如下文件类型:{}。'.format(pathname, '、'.join(self._handle_postfix)))elifos.path.isdir(full_pathname):for relpath, _, files inos.wal