Using comtypes, you can convert any file, where input and output filenames are given as commandline arguments.
For more details about comtype, click on this link
Look at the following code,
import sys
import os
import comtypes.client
wdFormatPDF = 17
in_file = os.path.abspath(sys.argv[1])
out_file = os.path.abspath(sys.argv[2])
word = comtypes.client.CreateObject('Word.Application')
doc = word.Documents.Open(in_file)
doc.SaveAs(out_file, FileFormat=wdFormatPDF)
doc.Close()
word.Quit()
You can also use pywin32, which would be same except:
import win32com.client
then,
word = win32com.client.Dispatch('Word.Application')
Wanna become a python expert? Come and join: Python ceritification course
For more details about python, do check out..