Forum: Ruby Dot matrix and Ruby !

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Gugão (Guest)
on 2007-02-24 12:34
Hi all, I´d like to do a class to print into a lx-300 printer ! i would
send parameters like, coordenates X,Y, condensed, draft, roman etc. I
have the printer´s manual, Is there a command in pure Ruby to send or
redirect to printer ?
Im searching without success !

thanks any help !
Robert K. (Guest)
on 2007-02-24 14:01
(Received via mailing list)
On 24.02.2007 11:34, Gugão wrote:
> Hi all, I´d like to do a class to print into a lx-300 printer ! i would
> send parameters like, coordenates X,Y, condensed, draft, roman etc. I
> have the printer´s manual, Is there a command in pure Ruby to send or
> redirect to printer ?
> Im searching without success !

If the printer is directly attached you can usually send commands and
control sequences directly to the printer port (on Windows typically
"LPT1:", on Linux I believe it's /dev/lpt).  Just make sure you open
that device in binary mode.

File.open("/dev/lpt", "wb") do |printer|
   printer.write("text and control sequences")
   # ...
   printer.flush
end

Maybe you have to add some more mode flags to ensure exclusive access to
the printer.

The standard way however would be to use your operating system's print
subsystem - if it has a driver for your kind of printer.

Kind regards

  robert
This topic is locked and can not be replied to.