Convert .doc to .pdf
Marco Nawijn
nawijn at gmail.com
Mon Jun 14 10:01:42 EDT 2010
On 14 jun, 13:19, Thales <thales.... at gmail.com> wrote:
> Good morning,
>
> I need to convert some files from .doc to .pdf. I've googled it a
> little bit and all the solutions I've found used the OpenOffice API,
> but I can't use it.
>
> Anybody knows a library that I can use to do it?
>
> Thanks
What about using the win32 API and use the free PDFCreator (http://
sourceforge.net/projects/pdfcreator/) PDF printer?
This should be very simple (code untested, but should be roughly OK):
- Instantiate MS/Word application
>> from win32com.client import Dispatch
>> app = Dispatch('Word.Application')
- Open your document
>> doc = app.Documents.Open("demo.doc")
- Print to PDF
>> app.ActivePrinter = "PDFCreator"
>> app.PrintOut(....)
The PrintOut call is a little tricky. I normally try to decode and
guess the Python call from the corresponding VisualBasic code I record
with the macro recording facility. I know there are more sophisticated
methods out there, but I never tried them.
Regards,
Marco
More information about the Python-list
mailing list