You can use OpenOffice if it is available on the system.
import subprocess
import shutil
input_filename = 'input.doc'
output_filename = 'output.pdf'
p = subprocess.Popen(['unoconv', '--stdout', input_filename], stdout=subprocess.PIPE)
with open(output_filename, 'w') as output:
shutil.copyfileobj(p.stdout, output)
You can also see the source code unoconvif you want to do this directly with Python bindings for UNO / OpenOffice COM.
source
share