我正在尝试将打印机作业语言命令发送到 HP 4515 打印机。但是,打印机不打印任何内容。下面是我的代码。打印机位于远程,我只能请那里的人检查是否打印了任何内容。不幸的是,什么都没有打印出来。PJL 命令的格式不是很好吗?如何使用 Java 和 PJL 获取工作状态?
socket = new Socket("192.168.1.101", 9100);
out = new DataOutputStream(socket.getOutputStream());
DataInputStream input = new DataInputStream(socket.getInputStream());
final char ESC = 0x1b;
final String UNESCAPED_UEL = "%-12345X";
String UEL = ESC + UNESCAPED_UEL;
out.writeBytes(UEL);
out.writeBytes("@PJL\r\n");
//out.writeBytes("@PJL SET MEDIASOURCE = TRAY2\r\n"); //I tried this line of code as well
out.writeBytes("@PJL SET PAPER = LETTER\r\n");
out.writeBytes("@PJL ENTER LANGUAGE = PDF\r\n");
for(int i=0; i<copies; i++) {
out.write(ps, 0, ps.length); //ps is of type byte[]. It contains the content of PostScript file
}
out.flush();
打印机的纸张设置:
TRAY 1 SIZE
TRAY 1 TYPE
TRAY 2 SIZE LETTER
UNIT OF MEASURE
X DIMENSION INCHES (5.83 - 8.5)
Y DIMENSION INCHES (8.27 - 14.0)
TRAY 2 TYPE