爱普生TM-T70 Java打印

时间:2013-02-13 11:31:21

标签: java printing epson javapos

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

感谢。

2 个答案:

答案 0 :(得分:2)

对于我们的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();
}
}

答案 1 :(得分:0)

这个剪纸

Socket sock = new Socket(IP_printer, 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.print(""+(char)29+(char)86+(char)0);