Star webPRNT User's Manual

StarWebPrintTrader.js

Sends Star webPRNT Request Element and checks status from received Star webPRNT Request Element.

Constructor

NameDescription
StarWebPrintTraderCreates StarWebPrintTrader object.

Method

NameDescription
sendMessagesendMessage Sends Star webPRNT Request Element.
isCoverOpenCover open is checked.
isOffLineOffline/Online is checked.
isCompulsionSwitchCloseCompulsion switch is checked.
isEtbCommandExecuteETB command execute is checked.
isHighTemperatureStopHigh temperature stop is checked.
isNonRecoverableErrorNon recoverable error is checked.
isAutoCutterErrorAuto cutter error is checked.
isBlackMarkErrorPaper separator detection error is checked.
isPaperEndPaper end is checked.
isPaperNearEndPaper near end is checked.
isPaperPresentPaper in the paper exit is checked.
isRollPositionErrorRoll position error is checked.
extractionEtbCounterETB counter is extracted.

Property

NameDescription
onReceiveCommunication success event.
onErrorCommunication error event.
timeoutCommunication timeout time. (ms)
holdprint_timeoutTimeout value for awaiting paper removal. (ms)

Star Printer Compatibility Chart

Please refer to the interface compatibility table by printer model here.

POS Printer
NameFVP
10
TSP
650II
TSP
650II
SK
TSP
700II
TSP
800II
mPOPmC-
Print2
mC-
Print3
TSP
100IV
TSP
100IV
SK
mC-
Label3
sendMessage*1
isCoverOpen
isOffLine
isCompulsionSwitchClose
isEtbCommandExecute
isHighTemperatureStop
isNonRecoverableError
isAutoCutterError
isBlackMarkError-----
isPaperEnd
isPaperNearEnd--✓ *2-
isPaperPresent-------
isRollPositionError--------
extractionEtbCounter

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)
NameSM-S220i
(Excluding Jp model)
SM-S230iSM-T300iSM-T400i
sendMessage*1 *2
isCoverOpen
isOffLine
isCompulsionSwitchClose----
isEtbCommandExecute----
isHighTemperatureStop----
isNonRecoverableError----
isAutoCutterError----
isBlackMarkError----
isPaperEnd
isPaperNearEnd----
isPaperPresent----
isRollPositionError----
extractionEtbCounter----

*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)
NameSM-S220i
(Excluding Jp model)
SM-S230iSM-T300iSM-T400iSM-L200SM-L300
sendMessage*1 *2
isCoverOpen
isOffLine
isCompulsionSwitchClose------
isEtbCommandExecute
isHighTemperatureStop
isNonRecoverableError------
isAutoCutterError------
isBlackMarkError
isPaperEnd
isPaperNearEnd------
isPaperPresent------
isRollPositionError------
extractionEtbCounter

*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

NameDescriptionObject typeOmission
urlSpecifies Star webPRNT endpoint URL
Note: When a url is omitted, it should be specified by sendMessage method.
String-
checkedblockSpecifies waiting for the completion of printing
  • true … Wait for the completion of printing
  • false … Not wait for the completion of printing
Booleantrue
papertypePaper type
  • normal … Nomal paper
  • black_mark … Black mark paper
  • black_mark_and_detect_at_power_on … Black mark paper (Detect at power on)
String-
timeoutCommunication timeout time (ms)Number90000
holdprint_timeoutTimeout 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.
Number10000

Return value

DescriptionObject type
StarWebPrintTrader objectStarWebPrintTrader
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

NameDescriptionObject typeOmission
urlSpecifies 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-
requestList of Star webPRNT Request ElementStringCan't be omitted
papertypePaper 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

DescriptionObject 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

Cover open is checked.

syntax

isCoverOpen(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Cover status
  • true … Open
  • false … Close
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.

syntax

isOffLine(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject 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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Compulsion switch
  • true … Close
  • false … open
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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject 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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Stopped by high head temperature
  • true … Yes
  • false … No
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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Non recoverable error
  • true … Yes
  • false … No
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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Auto cutter error
  • true … Yes
  • false … No
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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Paper separator detection error
  • true … Yes
  • false … No
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

Paper end is checked.

syntax

isPaperEnd(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Paper end
  • true … Yes
  • false … No
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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Paper near end
  • true … Yes
  • false … No
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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject 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

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Roll position error
  • true … Yes
  • false … No
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>

extractionEtbCounter

ETB counter is extracted.

syntax

extractionEtbCounter(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
ETB counterNumber
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) {
      alert('EtbCounter = ' + trader.extractionEtbCounter({traderStatus:response.traderStatus}).toString();
  }

    trader.sendMessage({request:request});
}
// -->
</script>

onReceive

Communication success event.

syntax

function(response);

Parameter

NameDescriptionObject type
traderSuccessSuccess code
  • true … Printing succeeded
  • false … Printing failed
Boolean
traderCodeResult code
  • 0 … Success
  • 1100 … Printer off line(On error)
  • 2001 … Printer busy(In use with another device: Need to resend data)
Number
traderStatusStar Automatic Status
Note. Refer to the command specifications.
String
statusStatus property of XMLHttpRequest
Note. Refer to the XMLHttpRequest specifications.
Number
responseTextResponseText 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

NameDescriptionObject type
statusStatus property of XMLHttpRequest
Note. Refer to the XMLHttpRequest specifications.
Number
responseTextResponseText 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>