Converting office files to PDF

Goermezer, Mustafa (PROSTE) extern.mustafa.goermezer at volkswagen.de
Tue Mar 2 12:44:12 CET 2004


Hello,

with CoInitializeEx it is possible for word, excel or powerpont to run in
multiple instances. So you can build a webbased converter to convert Office
documents with spyce and mod_python (I have tested it, it runs fine !):

Example for multiple instances:

pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)
myWord = win32com.client.DispatchEx('Word.Application')
myWord.Application.ActivePrinter="Printer name"
myDoc = myWord.Documents.Open("filename.doc", False, False, False)#please
see VBAWD10.CHM in Office directory
myDoc.Saved=1
myWord.PrintOut(True, False, 0, "postscriptfile.ps") ##please see
VBAWD10.CHM in Office directory
while myWord.BackgroundPrintingStatus > 0:
	time.sleep(1)
myDoc.Close()
myWord.Quit()
del myDoc
del myWord
Ghost() #ghostscript-command to convert created postscript file to PDF
pythoncom.CoUninitialize()

A ready script to convert files in commandline is on my homepage
www.goermezer.de.

Python rulez !!!

Mustafa





More information about the Python-list mailing list