We have a kiosk application in which we used to give receipt prints using windows print. Now we have a classid clsid:CCB90152-B81E-11D2-AB74-0040054C3719 and few functionalities in them which I need to use to print directly using this object rather using windows print. We even have some code related to that and I have tried to use some of that code to print a sample message. I was unsuccessful.
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>
and
doprinterinit()
function called is below.
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;
}
}
I go to device not enabled alert.. Please can somebody help me. I don't know how to deal with this.