Re: Printing in Ruby




On Feb 18, 2006, at 1:23 PM, Alexandru Toma wrote:

It seems there is not a lot of information on this subject so I have a
few questions:

1. How can you do simple printing from Ruby? If you have a string how
can you print it? At the very least I would like to be able to select
the size and maybe the font from the printer's ROM. I know that you
could do this in the DOS days by sending a few control codes dirrectly
to the parallel port and then the text you wanted to print (this worked
for dot matrix printers where you had a manual which detailed all those
control codes). How would you do this in Ruby? Also, would it be
possible to do the same for modern inkjet or laser printers? Would it
also be possible to do this in a platform independent way? (I'm more
interested in Linux, but it would be great if the same code also worked
on Windows)

2. Would it be possible to do something like the above but for USB
printers? How?

3. How would you do more advanced printing? I know of ruby-cups... are
there other alternatives? How about Windows?

4. I have a program (it's actually a Rails application) that generates
PDFs using PDF::Writer. How would I be able to print the PDFs dirrectly
without having to save them or open them in a browser... I just want to
send them directly to the printer after they are generated. Ruby-cups
seems to have .printFile which will print an existing file but, as I
said, I don't want to save the file first. Can I just pipe the generated
file to some application? Are there more ellegant ways of doing this?
How about Windows?


I'm sorry for asking so many questions at once. If you could answer even
just one of them I would be very grateful. Also, if you have any links
about the subject or you know of other discussions on the topic that
would help as well.

Many thanks in advance.

Alex

--
Posted via http://www.ruby-forum.com/.


assuming cups or lpd is setup for pdfs you can just shell out to lpr $file_name. As far as windows goes I'm sure win32api or win32ole can get you where you need to be.


.



Relevant Pages

  • Re: XP Pro/IE printing problem
    ... Repair Internet Explorer Printing Errors ... Printing Solution Center for Windows Products ... Resources for Troubleshooting Printing Problems in Windows XP ... > Looked in Printers and Faxes and there are not printers ...
    (microsoft.public.windowsxp.general)
  • Printer Problems
    ... windows NT 4.0 We just recently migrated to Windows 2000. ... We used print migrator to migrate the printers since we ... a from number that prints in sequence to the correct form so that the batch ... Since the upgrade, the batch printing has ...
    (microsoft.public.win2000.printing)
  • Re: Four options to connect Macs to Windows 2003 file shares, pros and cons?
    ... Right now we do straight IP printing. ... way where they can browse or hit a web page that lists all the printers ... installs with drivers pulled from the server. ... With Windows Server's built-in Print Services for Macintosh you won't ...
    (microsoft.public.win2000.macintosh)
  • Printing in Ruby
    ... How can you do simple printing from Ruby? ... for dot matrix printers where you had a manual which detailed all those ... How about Windows? ...
    (comp.lang.ruby)
  • Re: Determining Available Paper Sizes on Printer
    ... I looped through only the sizes given in the VB ... I'm afraid printing in Windows is still not an exact science, at least as far as paper sizes or special printing arrangements is concerned. ... Some printers are bristling with sensors that detect the size of paper in each available tray and some are not, and even for those that are there is still no "standard" way of communicating such information to Windows. ... Or in fact it could be that the printer driver you are using is a "generic for the model range" driver that can be used for various models in the range. ...
    (microsoft.public.vb.general.discussion)