[Tutor] Default printer in Windows

Michael Montagne Michael Montagne <montagne@boora.com>
Tue, 8 Oct 2002 09:27:38 -0700


>On 08/10/02, from the brain of alan.gauld@bt.com tumbled:

> > I'm trying to automate printing pdf files from zope.  I'm planning on
> > converting them to postscript and then copying them right to the
> > printer.  But I need the user's default printer.  Can it be 
> > retrieved by python? 
> 
> What platform?
> 
> If it's Unix then it might be defined in the PRINTER environment 
> variable - although this is far from universal.
> 
> If it's Windoze then just printing to the PRN or LPT ports 
> should work provided the printer is a real postscript printer
> (if the postscvript processing is done in a device driver 
> the raw data approach may not work!).
> 
> There are also things you can do with the registry but thats 
> starting to get into using the WSH COM object model or Win32API 
> which may lead to its own problems within a Zope architecture.
> 
> BTW which printer are you printing on? The client browser end 
> or the Zope server end? It makes a big difference! The above 
> all assumes the server end, if its the client things just got 
> a whole heap more complex!
> 
> Alan g.
> Author of the 'Learning to Program' web site
> http://www.freenetpages.co.uk/hp/alan.gauld

It's Windoze and I'm trying to print to a printer defined on the client
machine.  My latest approach is to use this:
os.system('"c:\program files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe /p /h
e:\\mjm\\bor.pdf"')
to print a file named e:\\mjm\\bor.pdf".
It will only work if everyone's Acrobat.exe is in the same place, but
perhaps I can try a couple of different locations.  All I need is to get
the filename from zope and, in theory, it should print on the default
printer for the machine that Acobat is installed (the  client).
Untested but I hope it works cause the alternatives seem very complex.

-- 
  Michael Montagne  [montagne@boora.com]   503.226.1575 
--