1

참조 (EPOS-인쇄 API/XML) :
https://download.epson-biz.com/modules/community/index.php?content_subject=ePOS-Print%20API/XML

간단한 테스트 웹 사이트 :

print.html

<script type="text/javascript" src="js/epos-print-3.0.0.js"></script> 

코드

function printTest() { 
    // open print dialog 
    $('#print').dialog('open'); 

    // 
    // build print data 
    // 

    // create print data builder object 
    var builder = new epson.ePOSBuilder(); 

    builder.addText('Test Print\n'); 
    builder.addFeedLine(1); 

    // append paper cutting 
    builder.addCut(); 

    // 
    // send print data 
    // 

    // create print object 
    var url = 'http://192.168.x.x/cgi-bin/epos/service.cgi?devid=local_printer&timeout=6000'; 
    var epos = new epson.ePOSPrint(url); 

    // register callback function 
    epos.onreceive = function (res) { 
     // close print dialog 
     $('#print').dialog('close'); 
     // print failure 
     if (!res.success) { 
      // show error message 
      $('#receive').dialog('open'); 
     } 
    } 

    // register callback function 
    epos.onerror = function (err) { 
     // close print dialog 
     $('#print').dialog('close'); 
     // show error message 
     $('#error').dialog('open'); 
    } 

    // send 
    epos.send(builder.toString()); 

} 
service.cgi에 515,

요청 :

<?xml version="1.0" encoding="utf-8"?> 
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Body> 
     <epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print"> 
      <text>Test Print!!&#10;</text> 
      <feed line="1"/> 
      <cut/> 
     </epos-print> 
    </s:Body> 
</s:Envelope> 

응답 엡손 API 설명서 (상태 : 0x00000001 = TM 프린터로부터 응답 없음)

<?xml version="1.0" encoding="UTF-8" ?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Body> 
     <response success="false" code="EX_TIMEOUT" status="1" xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print" /> 
    </soapenv:Body> 
</soapenv:Envelope> 

나 서비스 URL에게 다른 장치를 변경하면

var url = 'http://192.168.x.x/cgi-bin/epos/service.cgi?devid=other_printer&timeout=6000'; 

올바른 요청

Sucess="False" code="DeviceNotFound" status="0" 

Windows 응용 프로그램 예를 들어 동일한 응답 :

Public Class Form1 

    ' URL of ePOS-Print supported TM printer 
    Private address As String = "http://192.168.x.x/cgi-bin/epos/service.cgi?devid=local_printer&timeout=10000" 

    ' XML namespace 
    Private soap As XNamespace = "http://schemas.xmlsoap.org/soap/envelope/" 
    Private epos As XNamespace = "http://www.epson-pos.com/schemas/2011/03/epos-print" 

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 

     ' Create print document 
     Dim req As XElement = _ 
      <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
       <s:Body> 
        <epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print"> 
         <text lang="en" smooth="true">Intelligent Printer&#10;</text> 
         <cut/> 
        </epos-print> 
       </s:Body> 
      </s:Envelope> 

     ' Send print document 
     Dim client As WebClient = New WebClient() 
     client.Headers.Set("Content-Type", "text/xml; charset=utf-8") 
     AddHandler client.UploadStringCompleted, AddressOf UploadStringCompletedEventHandler 
     client.UploadStringAsync(New Uri(address, UriKind.Absolute), req.ToString()) 

    End Sub 

    ' Receive response document 
    Private Sub UploadStringCompletedEventHandler(sender As Object, e As UploadStringCompletedEventArgs) 

     If (e.Error IsNot Nothing) Then 
      MessageBox.Show(e.Error.Message) 
     Else 
      'Parse response document 
      Dim res As XElement = XElement.Parse(e.Result) 
      Dim c = From el In res.Descendants(epos + "response") Select el.Attribute("success") 
      MessageBox.Show(c.First().Value) 
     End If 

    End Sub 

End Class 

답변

0

두 가지 가능성 :

프린터는 local_printer 다른 장치 ID가 - 구성 페이지를 확인합니다.

또는 ePOSPrint() 함수는 URL 보내기를 직접 허용하지 않습니다. 내가 (내가 지금 같은 프린터 응용 프로그램을 구축하는 중이 야) 내 첫 번째 테스트 페이지에있는 것은 당신에 대한 다른 같습니다

var epos = new epson.ePOSPrint(); 
epos.address = 'http://192.168.0.1/cgi-bin/epos/services.cgi?devid=local_printer&timeout=6000'; 

참고 빈 () 방법과 URL이 초기화 후 제공됩니다. 내 유일한 추측이 장치 ID local_printer이 잘못되었다고, 그래서 확인 후


, 그것은, 당신이 그것을 가지고있는 것처럼 함수에 매개 변수로 URL을 제출 않습니다이 다른 테스트 코드처럼 보인다.

+0

하지만 구성 페이지에 DeviceId와 같은 것이 없기 때문에 어떻게 장치 ID를 얻을 수 있습니까? – Kashyap

+0

프린터에 더 이상 액세스 할 수 없지만 "local_printer"가 프린터의 원래 이름 (= 장치 ID) 이었으므로 여기부터 시작하겠습니다. – semmelbroesel

+0

#semmelbroesel. 뭔가 발견되었습니다 프린터 구성 페이지 중 일부가 다릅니다. 나는 TM-U220-B와 TM-88V-i를 많이 가지고있는 TM82-I을 가지고있다. 구성 페이지에서 장치 ID를 설정할 수 있습니다. 의 TM-82-I. – Kashyap

관련 문제