StarWebPrintTrader.js
Sends Star webPRNT Request Element and checks status from received Star webPRNT Request Element.
Constructor
Method
Property
Star Printer Compatibility Chart
Please refer to the interface compatibility table by printer model here.
POS Printer
IFBD-HE07X/HE08X/BE07X (TSP650IISK: Ver5.1.0 or later, Others: Ver3.1.0 or later)
IFBD-HI01X (TSP650IISK: Ver1.9.0 or later, Others: Ver1.1.0 or later)
*1 Waiting for completion of printing is fixed to valid for Bluetooth/USB printers.
The named argument ’checkedblock' does not work.
*2 Except MCP30
Mobile Printer (ESC/POS)
*1 Waiting for completion of printing is fixed to valid for Bluetooth printers.
The named argument ’checkedblock' does not work.
*2 The named argument 'papertype' does not work.
Mobile Printer (StarPRNT)
*1 Waiting for completion of printing is fixed to valid for Bluetooth printers.
The named argument ’checkedblock' does not work.
*2 The named argument 'papertype' does not work.
StarWebPrintTrader
Creates StarWebPrintTrader object.
syntax
StarWebPrintTrader(args);
Parameter
Name | Description | Object type | Omission |
url | Specifies Star webPRNT endpoint URL Note: When a url is omitted, it should be specified by sendMessage method. |
String | - |
checkedblock | Specifies waiting for the completion of printing
- true … Wait for the completion of printing
- false … Not wait for the completion of printing
| Boolean | true |
papertype | Paper type
- normal … Nomal paper
- black_mark … Black mark paper
- black_mark_and_detect_at_power_on … Black mark paper (Detect at power on)
| String | - |
timeout | Communication timeout time (ms) | Number | 90000 |
holdprint_timeout | Timeout value for awaiting paper removal (ms) * Set a value that is shorter than "timeout" parameter.
If a longer time is set, "timeout" parameter will take priority. | Number | 10000 |
Return value
Description | Object type |
StarWebPrintTrader object | StarWebPrintTrader |
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.sendMessage({request:request});
}
// -->
</script>
sendMessage
Sends Star webPRNT Request Element and checks status from received Star webPRNT Request Element.
syntax
sendMessage(args);
Parameter
Name | Description | Object type | Omission |
url | Specifies Star webPRNT endpoint URL Note: When a url is omitted, it should be specified by StarWebPrintTrader constructor. |
String | - |
checkedblock |
Specifies waiting for the completion of printing
- true … Wait for the completion of printing
- false … Not wait for the completion of printing
Note: When a checkedblock is omitted, the value specified by StarWebPrintTrader constructor should be used. | Boolean | - |
request | List of Star webPRNT Request Element | String | Can't be omitted |
papertype | Paper type
- normal … Nomal paper
- black_mark … Black mark detection valid
- black_mark_and_detect_at_power_on … Black mark detection valid with detect at power on
- gap … Gap detection valid for die-cut label paper, etc
- gap_and_detect_at_power_on … Gap detection valid with detect at power on for die-cut label paper, etc
Note: When a papertype is omitted, the value specified by StarWebPrintTrader constructor should be used.
If not specified by StarWebPrintTrader constructor either, it is an unset status. | String | - |
Return value
Description | Object type |
- | - |
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.sendMessage({request:request});
}
// -->
</script>
isCoverOpen
syntax
isCoverOpen(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Cover status
| Boolean |
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isCoverOpen({traderStatus:response.traderStatus})) {
alert('CoverOpen');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isOffLine
Offline/Online is checked.
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Offline/Online status
- true … Offline
- false … Online
| Boolean |
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isOffLine({traderStatus:response.traderStatus})) {
alert('OffLine');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isCompulsionSwitchClose
Compulsion switch close is checked.
syntax
isCompulsionSwitchClose(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Compulsion switch
| Boolean |
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isCompulsionSwitchClose({traderStatus:response.traderStatus})) {
alert('CompulsionSwitchClose');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isEtbCommandExecute
ETB command execute is checked.
syntax
isEtbCommandExecute(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
ETB command
- true … Executed
- false … Not executed
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isEtbCommandExecute({traderStatus:response.traderStatus})) {
alert('EtbCommandExecute');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isHighTemperatureStop
High temperature stop is checked.
syntax
isHighTemperatureStop(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Stopped by high head temperature
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isHighTemperatureStop({traderStatus:response.traderStatus})) {
alert('HighTemperatureStop');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isNonRecoverableError
Non recoverable error is checked.
syntax
isNonRecoverableError(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Non recoverable error
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isNonRecoverableError({traderStatus:response.traderStatus})) {
alert('NonRecoverableError');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isAutoCutterError
Auto cutter error is checked.
syntax
isAutoCutterError(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Auto cutter error
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isAutoCutterError({traderStatus:response.traderStatus})) {
alert('AutoCutterError');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isBlackMarkError
Paper separator detection error is checked.
syntax
isBlackMarkError(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Paper separator detection error
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isBlackMarkError({traderStatus:response.traderStatus})) {
alert('BlackMarkError');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isPaperEnd
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Paper end
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isPaperEnd({traderStatus:response.traderStatus})) {
alert('PaperEnd');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isPaperNearEnd
Paper near end is checked.
syntax
isPaperNearEnd(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Paper near end
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isPaperNearEnd({traderStatus:response.traderStatus})) {
alert('PaperNearEnd');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isPaperPresent
Paper in the paper exit is checked.
syntax
isPaperPresent(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Paper exit
- true … Paper is present at the paper exit.
- false … Paper is not present at the paper exit.
| Boolean |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isPaperPresent({traderStatus:response.traderStatus})) {
alert('PaperPresent');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
isRollPositionError
Roll position error is checked.
syntax
isRollPositionError(args);
Parameter
Name | Description | Object type | Omission |
traderStatus | traderStatus property of response passed to the onReceive event | String | Can't be omitted |
Return value
Description | Object type |
Roll position error
| Boolean |
Example
// --> <script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!-- function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
if (trader.isRollPositionError({traderStatus:response.traderStatus})) {
alert('RollPositionError');
}
}
trader.sendMessage({request:request});
}
// -->
</script>
onReceive
Communication success event.
syntax
function(response);
Parameter
Name | Description | Object type |
traderSuccess | Success code
- true … Printing succeeded
- false … Printing failed
| Boolean |
traderCode | Result code
- 0 … Success
- 1100 … Printer off line(On error)
- 2001 … Printer busy(In use with another device: Need to resend data)
| Number |
traderStatus | Star Automatic Status Note. Refer to the command specifications. | String |
status | Status property of XMLHttpRequest Note. Refer to the XMLHttpRequest specifications. | Number |
responseText | ResponseText property of XMLHttpRequest Note. Refer to the XMLHttpRequest specifications. | String |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
var msg = '- onReceive -\n\n';
msg += 'TraderSuccess:' + response.traderSuccess + '\n';
msg += 'TraderCode:' + response.traderCode + '\n';
msg += 'TraderStatus:' + response.traderStatus + '\n';
msg += 'Status:' + response.status + '\n';
msg += 'ResponseText:' + response.responseText;
alert(msg);
}
trader.onError = function (response) {
var msg = '- onError -\n\n';
msg += '\tStatus:' + response.status + '\n';
msg += '\tResponseText:' + response.responseText;
alert(msg);
}
trader.sendMessage({request:request});
}
// -->
</script>
onError
Communication error event.
syntax
function(response);
Parameter
Name | Description | Object type |
status | Status property of XMLHttpRequest Note. Refer to the XMLHttpRequest specifications. | Number |
responseText | ResponseText property of XMLHttpRequest Note. Refer to the XMLHttpRequest specifications. | String |
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.onReceive = function (response) {
var msg = '- onReceive -\n\n';
msg += 'TraderSuccess:' + response.traderSuccess + '\n';
msg += 'TraderCode:' + response.traderCode + '\n';
msg += 'TraderStatus:' + response.traderStatus + '\n';
msg += 'Status:' + response.status + '\n';
msg += 'ResponseText:' + response.responseText;
alert(msg);
}
trader.onError = function (response) {
var msg = '- onError -\n\n';
msg += '\tStatus:' + response.status + '\n';
msg += '\tResponseText:' + response.responseText;
alert(msg);
}
trader.sendMessage({request:request});
}
// -->
</script>
If the status is 413 (Payload Too Large), divide the request by 300mm and execute the sendMessage method again.
example: 300mm(2400 dots)
<StarWebPrint><bitImage x=576, y=2400> ... </bitImage></StarWebPrint>
timeout
Communication timeout time for StarWebPrintTrader (ms)
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.timeout = 120000;
trader.sendMessage({request:request});
}
// -->
</script>
holdprint_timeout
StarWebPrintTrader paper removal wait timeout time (ms)
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
var trader = new StarWebPrintTrader({url:url});
trader.holdprint_timeout = 30000;
trader.sendMessage({request:request});
}
// -->
</script>