我需要使用 Java 打印到 Epson TM-T70 打印机(以太网版)。我找不到有关此的文档。哪种方法最简单?也许使用JavaPOS?有例子吗?
谢谢。
对于我们的职位,我能够做到:
/* (non-Javadoc)
* @see be.intoit.pos.epsonagent.commands.Command#execute()
*/
public void execute() throws Exception {
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
StringBuilder builder = new StringBuilder();
builder.append(toPrint);
builder.append(EscapeCodeUtil.createEscapeCode(10));
PrintRequestAttributeSet aset= new HashPrintRequestAttributeSet();
aset.add(new MediaPrintableArea(100,400,210,160,Size2DSyntax.MM));
InputStream is = new ByteArrayInputStream(builder.toString().getBytes("UTF-8"));
Doc mydoc = new SimpleDoc(is, flavor, null);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
//print using default
DocPrintJob
job = defaultService.createPrintJob();
job.print(mydoc, aset);
}
util类在哪里:
public class EscapeCodeUtil {
public static String createEscapeCode(int ... codes)
{
StringBuilder sb = new StringBuilder();
for(int code : codes)
sb.append((char) code);
return sb.toString();
}
}
这剪纸
Socket sock = new Socket(IP_printer, 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.print(""+(char)29+(char)86+(char)0);