classid对象的功能

时间:2016-05-10 04:41:49

标签: javascript printing opos clsid

我们有一个自助服务终端应用程序,我们曾经使用Windows打印给出收据打印。现在我们有一个classid clsid:CCB90152-B81E-11D2-AB74-0040054C3719并且我们需要使用这些功能来直接使用这个对象而不是使用windows print进行打印。我们甚至有一些相关的代码,我试图使用一些代码来打印示例消息。我没有成功。

function printtext(){
        try{


        doPrinterInit();
        alert("after init print");
        doPrint(document.getElementById('fname').value, true, true);
        doPrintFeed();
        doCut();

        alert("printed");
        //document.getElementById('display').innerHTML = document.getElementById('fname').value;
        }
        catch(e){
            //alert('Error: ' + e.description);
        }

    }

</SCRIPT>
</HEAD>
<BODY onLoad="Initialize()">
<OBJECT ID="posPrinter" CLASSID="clsid:CCB90152-B81E-11D2-AB74-0040054C3719"></OBJECT>
    Utility File


        First name: <input type="text" name="fname" id="fname"><br>

        <button onclick="printtext()">Print</button>

    <div id="display"></div>
</BODY>
</HTML>

doprinterinit()调用的函数如下。

function doPrinterInit() {
    try {
        if (posPrinter.Open(PRINTER_ID) == 0) {
            alert("opened");
            if (posPrinter.Claim(CLAIM_TIMEOUT) == 0) {
            alert("claim timeout successful");
                posPrinter.DeviceEnabled = true;
                if (posPrinter.DeviceEnabled) {
                alert("fine device enabled");
                    // all is fine
                } else {
                alert("device not enabled");
                    throwException(105, 'doPrinterInit(): Could not Enable Printer', EVENT_TYPE_ERROR);
                }
            } else {
                throwException(posPrinter.ResultCode, 'doPrinterInit(): Could not Claim Printer in ' + CLAIM_TIMEOUT + ' ms', EVENT_TYPE_ERROR)
            }
        } else {
        alert("");
            throwException(posPrinter.ResultCode, 'doPrinterInit(): Could not Open Printer', EVENT_TYPE_ERROR);
        }
    } catch(e) {
        throw e;
    }
}

我转到设备未启用警报..请有人帮助我。我不知道该怎么处理。

0 个答案:

没有答案