Convert .doc to .pdf

Marco Nawijn nawijn at gmail.com
Mon Jun 14 12:48:55 EDT 2010


On 14 jun, 17:55, Thales <thales.... at gmail.com> wrote:
> On 14 jun, 11:01, Marco Nawijn <naw... at gmail.com> wrote:
>
>
>
>
>
> > 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
>
> Thanks for your help Marco, but it has to work on linux, not on
> windows. Is possible to import this win32com on linux systems? How?
>
> Thank you!

Nope. The win32 related packages only work on Windows systems.

Maybe Wine is an option? So running a genuine MS Office under Wine on
Linux?
Otherwise, your best bet is still OpenOffice (although you mention you
cannot use it)

Regards,

Marco



More information about the Python-list mailing list