Convert Word .doc to Acrobat .pdf files

Rune Strand rune.strand at gmail.com
Wed Mar 29 01:25:43 CEST 2006


kbperry wrote:
> Questions:
> Does Acrobat Pro, have some way to interface with it command-line (I
> tried searching, but couldn't find anything)?  Is there any other good
> way to script word to pdf conversion?
>
> Note:  The word documents do contain images, and lots of stuff besides
> just text.

The Acrobat Distiller installs (or van install) a Word VBS macro which
allows Word to Save As .PDF. It's easy to call from Python:

doc = "somefile.doc"
import win32com.client

# Create COM-object
wordapp = win32com.client.gencache.EnsureDispatch("Word.Application")

wordapp.Documents.Open(doc)
wordapp.Run("'!CreatePDFAndCloseDoc")  # the name of the macro for
Acrobat 6.0
wordapp.ActiveDocument.Close()
wordapp.Quit()

You'll probably wrap this in more logic, but it works.




More information about the Python-list mailing list