Epson TM-T70 Java printing



我需要用Java打印到Epson TM-T70打印机(以太网版本)。我找不到有关这方面的文档。哪种方法最简单?也许使用JavaPOS?有什么例子吗?

谢谢。

对于我们的pos,我能够做到:

/* (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);

相关内容

  • 没有找到相关文章

最新更新