views:

629

answers:

3

Using java, minus the exception handling, it is as simple as

FileOutputStream ostream = new FileOutputStream("\\\\host\\share");
PrintStream printStream = new PrintStream(ostream);
printStream.print("HELLO PRINTER");
printStream.close();
ostream.close();
+1  A: 

While I've never tried to print from Ruby, and while I don't have a Windows machine available to test on, it would seem to me that you don't want to be using the File class, but instead the IO class. You can see its documentation here: http://ruby-doc.org/core/classes/IO.html. It looks like it actually has Windows specific options, so take a look and if it's not too helpful, let me know why.

nakajima
Thanks for the help. I don't know why I was getting the error earlier but it is working fine now.
+1  A: 
File.open("\\\\host\\share") do |f|
  f.print("HELLO PRINTER#{12.chr}")
end
does not currently work with jruby
A: 

Hi,

I am new to ruby. I have a printer which is of USB port dosent have network. I wanted to print a PCL file to the printer using Ruby on windows. Please help me

Regards Manju

manju
Manju - you should probably start a new topic rather than asking a question in the answer section of an existing one.
Brian