Arno Dirlam wrote:> I recently searched for ways printing plain (but formatted) text
> directly to a receipt printer using ruby and stumbled upon wxruby,
> which seems to be a nice framework that would meet my requirements
> quite well.
>
> Using the printing.rb example and lots of tries I found a way to print
> text without dialogues:
<snip>
Thank you for posting a follow-up to your earlier question (which I''m
afraid I didn''t know the answer to). Having a record of successful code
snippets benefits everyone who uses the archives. It''s much
appreciated.
> The "D" in font "Control" tells the receipt printer to
open the cash
> drawer, which is connected to it. The problem is that it additionally
> prints a small slice of paper. The printer''s driver software can
> command the printer to just open the drawer without any printing,
> which is what I want to do with wxruby.
> I suppose that this is because of the hidden canvas that I use. And
> the canvas is always present no matter what I print on it, which is
> why an empty page is printed.
>
> The question is: Is there a way to send plain formatted text as a
> stream directly to the printer? I mean, without using a hidden canvas
> and submitting coordinates to draw text?
I haven''t used the Printing API in wxRuby enough to be sure if there is
a way to do this - I suspect not if you haven''t found it. It''s
based on
a canvas-page model AFAIK.
Other ways will depend on whether you''re using Windows or Linux. If
Windows I don''t know.
On Linux there are a set of command line tools to directly send print
jobs to and view the printer queue (eg ''lpr''). You''ll
need the device
name of the printer, and know how it receives data to print (since as
you say you need to send formatted data). Some printers have in-built
postscript interpreters so you could just send a raw postscript file
containined "D" in font "Control" that way. Or if not, you
can use
GhostScript with a device descriptor to turn a PS file into raw data
that your printer will understand.
The Linux Printing Faq might be useful:
http://www.tldp.org/HOWTO/Printing-Usage-HOWTO-2.html#ss2.2
http://www.tldp.org/HOWTO/Printing-Usage-HOWTO-3.html#ss3.2
hth
alex