Ruby의 Windows 프린터 공유에 원시 프린터 코드를 어떻게 작성합니까?

StackOverflow https://stackoverflow.com/questions/404975

  •  03-07-2019
  •  | 
  •  

문제

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

다른 팁

루비에서 인쇄하려고 시도한 적이 없지만 테스트 할 수있는 Windows 시스템이 없지만 사용하고 싶지 않은 것 같습니다. File 클래스, 대신 IO 수업. 여기에서 문서를 볼 수 있습니다. http://ruby-doc.org/core/classes/io.html. 실제로 Windows 특정 옵션이있는 것처럼 보이므로 살펴보고 너무 도움이되지 않으면 이유를 알려주십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top