12345678910111213141516171819202122 |
- import os
- from pathlib import Path
- from win32com.client import Dispatch
- wdFormatPDF = 17
- def doc2pdf(doc_file):
- in_file = str(Path(doc_file).absolute())
- out_file = in_file[:-4] + '.pdf'
- word = Dispatch('Word.Application')
- doc = word.Documents.Open(in_file)
- doc.SaveAs(out_file, FileFormat=wdFormatPDF)
- doc.Close()
- word.Quit()
- if __name__ == '__main__':
- doc2pdf(os.path.dirname(__file__) + '/data/RE6404Siebrecht.doc')
- # add_watermark_to_folder(os.path.dirname(__file__) + '/data/')
|