如何将原始打印机代码写入ruby的Windows打印机共享?
题
使用java,减去异常处理,就像
一样简单FileOutputStream ostream = new FileOutputStream("\\\\host\\share");
PrintStream printStream = new PrintStream(ostream);
printStream.print("HELLO PRINTER");
printStream.close();
ostream.close();
解决方案
File.open("\\\\host\\share") do |f|
f.print("HELLO PRINTER#{12.chr}")
end
其他提示
虽然我从来没有尝试过从Ruby打印,虽然我没有可用于测试的Windows机器,但在我看来你不想使用文件代码>类,而是
IO
类。您可以在此处查看其文档: http://ruby-doc.org/core/classes /IO.html 。看起来它实际上有Windows特定的选项,所以看看它是否有用,请告诉我原因。
不隶属于 StackOverflow