W. eWatson wrote:
I am writing a txt file. It's up to the user to print it using
Notepad or some other tool. I have no idea how to send it
directly to the printer, but I really don't want to furnish
that capability in the program. From Google, The Graphics
Device Interface (GDI).
If you're writing it to a text file and assuming that Notepad is
smart enough to properly handle form-feeds, I'm sorry, you'll be
disappointed...this says more about the brain-deadness of Notepad
than your optimism :-)
If you have a configurable destination, you might be able to do
something within your Python app like
if 'win' in sys.platform.lower():
default_dest = "lpt1:"
else:
default_dest = "/dev/lp0"
dest = config.get("printer", default_dest)
f = file(dest, 'wb')
f.write(my_output_with_ff)
# optionally
# f.write(chr(12))
# to eject the last page
f.close()
Otherwise, you'd have to write to something a default Windows
application would know how to handle with embedded
form-feeds/page-breaks (i.e., not Notepad as the default .txt
handler). My first thought would be to export it as RTF (there
was a good python RTF library I tinkered with one afternoon --
it's a quick google away) which should allow embedding
page-breaks, and even give you a fair bit of additional control
over other aspects like fonts and styles.
-tkc
--
http://mail.python.org/mailman/listinfo/python-list