Question

I need to print to an Epson TM-T70 printer (Ethernet version) with Java. I can't found documentation about this. Which is the simplest way? Maybe using JavaPOS? Is there some example?

Thanks.

Was it helpful?

Solution

for our pos, I was able to do:

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

}

Where The util class was:

public class EscapeCodeUtil {

public static String createEscapeCode(int ... codes)
{
    StringBuilder sb = new StringBuilder();

    for(int code : codes)
        sb.append((char) code);

    return sb.toString();
}
}

OTHER TIPS

This cut the paper

Socket sock = new Socket(IP_printer, 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.print(""+(char)29+(char)86+(char)0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top