Send output to printer

Jorgen Bodde jorgen.maillist at gmail.com
Wed Jun 25 02:49:02 EDT 2008


Hi,

It depends on how your printer can be accessed. Is there a driver for
it? The most simple way might be using ShellExecute (under windows)
but I found  no way to supress the print dialog.

Another way is using win32com module and instantiate an IE automation
object, which you feed a HTML page and issue a print. Be careful about
printing too fast allow it 4-5 seconds to process or successive print
jobs will fail.

Here is a snippet of code to get you on your way;

from win32com import client
ie = client.Dispatch("InternetExplorer.Application")
ie.Navigate(fn)      # fn = filename (to temp file) to print
time.sleep(2)
ie.ExecWB(6, 2)
time.sleep(2)
ie.Quit()
ie = None

For successive prints it is better to instantiate one IE object per
multiple print jobs, but once done, release it and set it up again.

- Jorgen






On Wed, Jun 25, 2008 at 6:54 AM, ajak_yahoo <arazak73 at yahoo.com.my> wrote:
> Need some help from you all,
>
> I already manage to write a program to print a packaging label.
>
> The output on screen is as below,
>
>
> Part Number   :  PWEE1111AA
> Quantity         :  100 pcs
> Lot Number     :  10A2008
> Customer        :  ABC Pte. Ltd.
>
>
> My questions is how can I send this output to my Panasonic KX-P1121 dot
> matric printer,
> Is it a module that i can used, previously i wrote my program using foxpro
> 2.6, i have no experience in python.
>
>
> Regards,
> Ajak
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list