Windows Printing using win32print

Timothy Grant tjg at hyperlinq.net
Tue Jun 26 05:41:05 CEST 2001


Thanks for the input I really appreciate it.

However, The printer name I am using is correct. In fact, when
single stepping through the code in the debugger, I can
actually see the job appear and then disappear from the queue.
Unfortunately nothing prints.

On Mon, Jun 25, 2001 at 07:35:59PM -0700, Emile van Sebille wrote:
> I'm not sure if this helps with your specific problem is, but I can say that
> you need to figure out the name the printer goes by.  I've seen different
> names for printers working with various applications in windows.  Here are
> two examples that I'm currently using.
> 
> destPrinter = r'NEC Silentwriter 95 v2011.111 on LPT1:'
> destPrinter = r"\\NT401\HP Laserjet 4000N Front Desk on NE02:"
> 
> I got the names by going into immediate mode from within Office 2000.  Here
> are my notes.
> 
> ## to figure out the printer name recognized in MS Office apps,
> ## - go into the app
> ## - print a document to the target printer
> ## - alt-F11 into visual basic
> ## - go into immediate mode
> ## - print Application.ActivePrinter
> ## - copy and paste the name in
> 
> Again, not sure it'll help, but hope it does.
> 
> --
> 
> Emile van Sebille
> emile at fenx.com
> 
> ---------
> "Timothy Grant" <tjg at hyperlinq.net> wrote in message
> news:mailman.993507818.30090.python-list at python.org...
> > I'm not much of a windows programmer, but I am in a situation
> > where I need to write a test programme that does a lot of very
> > small print jobs from a Windows box. I have downloaded
> > win32all, and cobbled together a little app that I think
> > should, maybe work, but doesn't.
> >
> > In my first iteration, I simply wrote a text file, then used
> > os.system('copy filename lpt1:') to print it. This worked just
> > fine, but one of the variables I need to test is how an
> > interaction with the actual Windows printers works. To that end
> > I started reading up on win32print. I was able to come up with
> > the following...
> >
> >
> > import win32print
> >
> > text2print = """
> > This is a test to see if I can get this text to actually print\n
> >
> >
> >
> > It will be multiple lines...\n
> >
> > Watch and see\n
> > """
> > printer = win32print.OpenPrinter('Tektronix Phaser 600 Extended')
> > jid = win32print.StartDocPrinter(printer, 1, ('TEST DOC',
> 'c:\\test\\test.tjg', 'RAW'))
> > bytes = win32print.WritePrinter(printer, text2print)
> > win32print.EndDocPrinter(printer)
> > win32print.ClosePrinter(printer)
> > print bytes
> >
> >
> > Now this is where my understanding of how things should work
> > gets a bit shaky. I have read that the WritePrinter() function
> > should send printer ready data. So since text2print is not in
> > ps or pcl native format, I'm curious as to whether I'm even
> > close.
> >
> > If I do need to send printer ready data, how do I create the
> > printer ready data from my print string?
> >
> > Thanks for any assistance you might be able to provide.
> >
> > --
> > Stand Fast,
> >     tjg.
> >
> > Timothy Grant                                www.hyperlinq.net
> > Chief Technology Officer                     tjg at hyperlinq.net
> > HyperLINq Technologies, Inc.                <>< (503) 246-3630
> > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
> > >>>>This machine was last rebooted:  20 days 22:08 hours ago<<
> >
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

-- 
Stand Fast,
    tjg.

Timothy Grant                                www.hyperlinq.net 
Chief Technology Officer                     tjg at hyperlinq.net 
HyperLINq Technologies, Inc.                <>< (503) 246-3630
>>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
>>>>This machine was last rebooted:  21 days  3:38 hours ago<<




More information about the Python-list mailing list