javaprintingepsonjavapos

Epson TM-T70 Java printing


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.


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();
    }
    }