Print to printer

A

avnit

I can't seem to figure out how to print with my printer using python.
I'm using Mac OSX 10.4. I was thinking maybe something with
applescript. Does anyone know?
 
M

Magnus Lycka

avnit said:
I can't seem to figure out how to print with my printer using python.
I'm using Mac OSX 10.4. I was thinking maybe something with
applescript. Does anyone know?

Mac OSX is unix, right?

This ought to work then:
Try to get 'lpr' or 'lp' to work from a command line.
You should be able to use 'lpstat -p' to figure out
printer names if you need that (then use 'lpr -P ps'
to print to a printer called ps.)
 
A

avnit

Do you know if there's a way to print a file? I'm trying to print an
HTML file, so your solution is good, but doesn't really work for me.
Just reading the HTML file and the printing the content obviously
wouldn't work. I also tried:

but apparently this function only takes strings as parameters.

Thanks.
 
M

Magnus Lycka

avnit said:
Do you know if there's a way to print a file? I'm trying to print an
HTML file, so your solution is good, but doesn't really work for me.
Just reading the HTML file and the printing the content obviously
wouldn't work. I also tried:


but apparently this function only takes strings as parameters.

Unless you have a strong desire to waste time and memory by opening
the file reading the content into a string and then call printer.write,
you could simply do something along the lines of this:

fn = 'path/to/file.ext'
printer = 'ps'
print_cmd = 'lpr -P %s %s'
os.system(print_cmd % (printer, fn))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,348
Members
48,034
Latest member
JaimieBarn

Latest Threads

Top