Printing with python

Florian Schulze florian.proff.schulze at gmx.net
Thu Oct 3 12:57:32 EDT 2002


On Mon, 30 Sep 2002 23:46:42 +0200 Grzegorz Makarewicz <mak at trisoft.com.pl> wrote:

> Florian Schulze wrote:
> > Hi!
> > 
> > I would like to know what solutions exist for printing (on paper) with
> > python. Preferable would be a crossplatform approach, but only for
> Windows
> > would be good enough. I also thought about using the reportlab pdf lib
> and
> > using the free Acrobat Reader for preview and printing. It has a nice
> API
> > and I don't think it will be too hard to send it to Acrobat Reader.
> > 
> > Any suggestions or thoughts about this?
> > 
> > Regards,
> > Florian Schulze
> > 
> > 
> > 
> 
> try DDE connection to AR:
> 
> import os
> import win32ui
> import dde
> 
> fname=os.path.join(os.getcwd(),'demo.pdf')
> server = dde.CreateServer()
> server.Create("PyAcroview")
> 
> conversation = dde.CreateConversation(server)
> 
> conversation.ConnectTo("acroview", "control")
> conversation.Exec("[DocOpen(%s)]" %fname)
> 
> --
> You can print, select pages and documents, ...
> 
> mak
> 
> 

I played with it a bit, but couldn't get it working.

If Acrobat Reader isn't already open ConnectTo fails. I tried to work
around that by starting Acrobat Reader first, but this produced other
problems.

I downloaded some DDE documentation about Acrobat and tried various
commads including your DocOpen, but most of them just don't work. I found
out later that I had to put the filename into "s, when it contained a
space.

I think I will use os.startfile for now, as this is the easiest way,
without messing with registry values to get the AcroRD32.exe path etc.

If you have some advice it would still be greatly appreciated though.

Thanks and regards,
Florian







More information about the Python-list mailing list