Skip to content

1. API Reference

API list

Constructor

Contents Description
PrinterManager A constructor of the PrinterManager class.

Methods

Contents Description
start Starts communication with the SDK server.
stop Disconnects from the SDK server.
doPrint Sends the data in the buffer to the printer and prints it.
appendText Adds text to the buffer.
appendBarcode Adds text to the buffer.
appendCut Adds a paper cut request to the buffer.
For a printer without autocutter, adds the paper feed up to the paper cut position to the buffer.
appendFeed Adds a paper feed request to the buffer.
appendMarkFeed Adds a paper form feed request of marked paper or label to the buffer.
appendDrawer Adds a request to open a cash drawer to the buffer.
appendBuzzer Adds a request for buzzer sounding to the buffer.
appendBinary Adds binary data to the buffer.
appendImage Adds an image to the buffer.
onDeviceStatus Specifies or cancels the callback function to be executed when the printer status changes.
doReset Resets the printer。
setInternationalCharacter Sets the international character set.
setCodePage Sets the codepage.
getVersion Gets the SDK version as the character string.

Common for Each Method

  • Each method cannot be executed in parallel. Do not execute the next method until the return value is returned after executing a method.

Return Value

The each method returns the following object as the return value unless otherwise instructions. (This object is hereafter referred to as the result object.)

Return Value

{
    [(Elements specific to each method),]
    errorCode: errorCode,
    errorString: errorString,
    errorExtendedString: errorExtendedString
}

Element

(Elements specific to each method)

Element specific to each method. See each method description for details. Methods with no return value listed in the method description have no element specific to the method.

errorCode

Error code. Type is numeric.

errorString

Error string. Type is a character string.

errorExtendedString

Error extension string. Stores error details. The type is a string.

Reference

  • In the "Syntax" section within each method description, optional elements are indicated by surrounding them with '[', ']'.

PrinterManager

A constructor of the PrinterManager class.

Syntax

public PrinterManager()

Parameter

None

Specifing parameters is not required.

Return Value

Returns an instance of the PrinterManager class.

start

Starts communication with the SDK server.

Syntax

async start( { [ lockDevice: lockDevice ] } )

Parameter

lockDevice

Specify whether the device should be locked so that it cannot be accessed by other hosts or software with a boolean.
When locking, the time to send a command to a device is reduced, but the device cannot be shared with other hosts.
Optional (default: false).
When the device goes to sleep, the lock may be temporarily unlocked.
Clicking the "Back" button or reloading the browser will disconnect communication with the SDK server. In that case, call the start method again.
When connecting to a device via Wireless LAN or Ethernet, the lock is canceld after the device's TCP Socket Port timeout period has elapsed since the start of the connection to the device or the last data transmission.

Description

Call this method before using any other methods in the PrinterManager class.
The buffer is cleared.
Select the device on the SDK server before calling this method. The device cannot be selected again on the SDK server until the stop method is called after this method is called.

Reference

  • The Web SDK server accepts only 1 connection at a time. When connecting from other pages, etc., terminate the connection with the Web SDK server by using the stop method on the currently connected Web page.
  • When the Windows PC or Android device goes into sleep, the connection to the Web SDK server is disconnected.
  • If a connection is made to the Web SDK server from a page that is not the original page, the Web SDK server will clear the data in the buffer it holds.
  • If the error code -605 (Error due to failure to connect to Web SDK server) is returned when executing each method, execute the start method after executing the stop method. The stop method may return an error.
  • If the error code -201 (Error due to timeout) is returned when executing the appendXXX method, execute the start method again. At the time, the buffer is cleared, so execute the appendXXX method again from the beginning.

stop

Terminates device status monitoring and connection to the Web SDK server.

Syntax

async stop( { } )

Parameter

None

Specify an empty object.

doPrint

Sents and prints the data in the buffer added by the appendXXX method.

Syntax

async doPrint( { [ timeout: timeout] } )

Parameter

timeout

Specifies the print timeout as a number. The unit is seconds.
The valid value is -1, 10 to 300. If -1 is specified, print timeout is disabled. If the Taken Mode of the printer setting is set to enabled, specify -1.
Optional (default: 90).

Return Value

Returns the result object containing the following elements.

printId

Returns the print ID as a number.

Description

Sends and prints the data stored in the buffer in the SDK server to the printer.
The maximum size of the buffer in the SDK server is 10 MB.
If the callback function is set for the onDeviceStatus, notices the completion of printing when printing is normally completed.
If an error is detected during printing, the completion of printing will not be notified.
The contents of the buffers in the SDK server are cleared in the following cases.

  • When calling start/stop method
  • When first calling to the appendXXX method after this method call.

appendText

Adds specified text to the buffer.

Syntax

async appendText( { text: text,
                    [bold: bold,]
                    [underline: underline,]
                    [reverse: reverse,]
                    [inversion: inversion,]
                    [font: font,]
                    [widthScale: widthScale,]
                    [heightScale: hightScale,]
                    [alignment: alignment] } )

Parameter

text

Specifies text data to add to the buffer as a string.
The data size that can be specified at 1 time is 16KB (16384 bytes).
Cannot be omitted.
The text data must be terminated with the line feed character '\n'. However, this excludes cases where you want to divide a line into multiple appendText calls and add them to the buffer, such as when you want to switch the font weight within a single line. In that case, add the line feed character '\n' to the end of the text data of the last appendText call.

bold

Specifies the setting of enable or disable of bold printing by the boolean.
Optional (default: false).

underline

Specifies the underline setting as a numerical value.
Specify one of the values in the table below.
Optional (default: 0).

underline Underline
0 No underline
1 1-dot underline
2 2-dot underline
reverse

Specifies the setting for reverse print by the boolean.
When specifying true, performs the reverse print.
Optional (default: false).

inversion

Specifies the setting for inversion print by the boolean.
When specifying true, performs the inversion print.
Optional (default: false).
Upright and inverted printing cannot be mixed in a single line.

font

Specifies the setting for character font by a string.
The valid value is either 'fontA' or 'fontB'.
Optional (default: 'fontA').

widthScale

Specifies the character scale (width) as a numerical value.
The valid value is from 1 to 8.
Optional (default: 1).
Kanji characters are magnified up to twice.

heightScale

Specifies the character scale (height) as a numerical value.
The valid value is from 1 to 8.
Optional (default: 1).
Kanji characters are magnified up to twice.

alignment

Specifies alignment as a numerical value.
The valid value is any of 'left', 'center', or 'right'.
Optional (default: 'left').
Alignment cannot be mixed within a single line.

Description

This method encodes the specified text data into printable text data by the printer based on setInternationalCharacter and setCodePage and adds it to the buffer.

appendBarcode

Adds a barcode to the buffer. See the thermal printer technical reference for the data formats that can be entered for each barcode.

・1D barcode printing

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       moduleSize: moduleSize,
                       barcodeHeight: barcodeHeight,
                       [hriPosition: hriPosition,]
                       [hriFont hriFont,]
                       [alignment: alignment,]
                       nwRatio: nwRatio } )

Parameter

symbol

Specifies a barcode symbol as a string. Specifies the following according to the barcode symbol to be printed.
Cannot be omitted.

symbol barcode symbol
'upcA' UPC A
'upcE' UPC E
'ean13' EAN13
'jan13' JAN13
'ean8' EAN8
'jan8' JAN8
'code39' CODE39
'code93' CODE93
'code128' CODE128
'itf' ITF
'codabar' CODABAR
'ean13Addon' EAN13 ADDON
'jan13Addon' JAN13 ADDON
'gs1OmniDirectional' GS1 Databar Omni Directional
'gs1Truncated' GS1 Databar Truncated
'gs1Limited' GS1 Databar Limited
'gs1Expanded' GS1 Databar Expanded
text

Specifies barcode data as a string.
Be sure to specify either the text or data element.

data

Specifies barcode data as blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Be sure to specify either the text or data element.

moduleSize

Specifies the width of the barcode as a numerical value.
Specify a value from 2 to 8.
Cannot be omitted.

barcodeHeight

Specifies the height (dot) of the barcode as a numerical value.
Cannot be omitted.

If the barcodeSymbol is one of the following, the valid value is from 1 to 255.
'upcA', 'upcE', 'ean13', 'jan13', 'ean8', 'jan8', 'code39', 'code93', 'code128', 'itf', 'codabar', 'ean13Addon', 'jan13Addon'
If the barcodeSymbol is one of the following, the valid value differs depending on the barcodeSymbol and moduleSize.
barcodeSymbol moduleSize valid value
'gs1OmniDirectional' 2 66 to 255
3 99 to 255
4 132 to 255
5 165 to 255
6 198 to 255
'gs1Truncated' 2 26 to 255
3 39 to 255
4 52 to 255
5 65 to 255
6 78 to 255
'gs1Limited' 2 20 to 255
3 30 to 255
4 40 to 255
5 50 to 255
6 60 to 255
'gs1Expanded' 2 68 to 255
3 102 to 255
4 136 to 255
5 170 to 255
6 204 to 255
hriPosition

Specifies HRI character print position as a numerical value.

hriPosition description
'none' Not print
'above' Above barcode
'below' Below barcode
'aboveBelow' Above and below barcode (both)
hriFont

Specifies HRI character print position as a numerical value.
The valid value is either 'fontA' or 'fontB'.
Optional (default: 'fontA').

alignment

Specifies alignment by a numerical value.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

nwRatio

Specifies NW ratio by the character string.
The valid value is any of '1:2', '1:2.5', or '1:3'.
Depending on the specified moduleSize and nwRatio, the width of wide element is set as shown in the following table.
Cannot be omitted.

moduleSize nwRatio
'1:2'

'1:2.5'

'1:3'
2 0.500 mm(4 dots) 0.625 mm(5 dots) 0.750 mm(6 dots)
3 0.750 mm(6 dots) 1.000 mm(8 dots) 1.125 mm(9 dots)
4 1.000 mm(8 dots) 1.250 mm(10 dots) 1.500 mm(12 dots)
5 1.250 mm(10 dots) 1.625 mm(13 dots) 1.875 mm(15 dots)
6 1.500 mm(12 dots) 1.875 mm(15 dots) 2.250 mm(18 dots)

Adds PDF417 to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       errorCorrection: errorCorrection,
                       row: row,
                       column: column,
                       moduleSize: moduleSize,
                       moduleHeight: moduleHeight,
                       [alignment: alignment,]
                       pdf417Symbol: pdf417Symbol } )

Parameter

symbol

Specifies barcode symbol by the character string.
Specifies the string 'pdf417'.
Cannot be omitted.

text

Specifies barcode data by the character string.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Be sure to specify either the text or data element.。

errorCorrection

Specifies the error correction level by the character string.
The valid value is any of '0', '1', '2', '3', '4', '5', '6', '7', or '8'.
Cannot be omitted.

row

Specifies the number of rows (row) by a numerical value.
The valid value is from 0 to 90.
If 0 is specified, the number of rows is automatically set. Cannot be omitted.

column

Specifies the number of columns in the data area by a numerical value.
The valid value is from 0 to 30.
If 0 is specified, the number of columns in the data area is automatically set. Cannot be omitted.

moduleSize

Specifies nominal fine element width by a numerical value.
The valid value is from 2 to 8.
Cannot be omitted.

moduleHeight

Specifies module height (dot) by a numerical value.
The valid value is from 2 to 127.
When the module height is set smaller, some barcode scanners may not read it. Set 3 or more for normal use.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

pdf417Symbol

Specifies the symbol of PDF417 by the character string.
The valid value is either of 'standard' or 'compact'.
Cannot be omitted.

Adds QR corde to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       errorCorrection: errorCorrection,
                       moduleSize: moduleSize,
                       [alignment: alignment]  } )

Parameter

symbol

Specifies string barcode symbol.
Specifies the character string 'qrCode'.
Cannot be omitted.

text

Specifies barcode data by the character string.
The version is automatically set according to the number of data specified by text.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
The version is automatically set according to the number of data specified by text.
Be sure to specify either the text or data element.

errorCorrection

Specifies the error correction level by the character string.
The valid value is any of 'l', 'm', 'h', or 'q'.
Cannot be omitted.

moduleSize

Specifies module size by a numerical value.
The valid value is from 2 to 16.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

・Pint Data Matrix

Adds Data Matrix to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                      [text: text,]
                      [data: data,]
                      dataMatrixModule: dataMatrixModule,
                      moduleSize: moduleSize,
                      [alignment: alignment] } )

Parameter

symbol

Specifies barcode symbol by the character string.
Specifies the character string 'dataMatrix'.
Cannot be omitted.

text

Specifies barcode data by the character string.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Be sure to specify either the text or data element.

dataMatrixModule

Specifies the number of Data Matrix modules by the character string.
The valid values, see below.
Cannot be omitted.

dataMatrixModule Number of module
'auto' Number of modules: Automatic
'10x10' Number of modules: 10×10
'12x12' Number of modules: 12×12
'14x14' Number of modules: 14×14
'16x16' Number of modules: 16×16
'18x18' Number of modules: 18×18
'20x20' Number of modules: 20×20
'22x22' Number of modules: 22×22
'24x24' Number of modules: 24×24
'26x26' Number of modules: 26×26
'32x32' Number of modules: 32×32
'36x36' Number of modules: 36×36
'40x40' Number of modules: 40×40
'44x44' Number of modules: 44×44
'48x48' Number of modules: 48×48
'52x52' Number of modules: 52×52
'64x64' Number of modules: 64×64
'72x72' Number of modules: 72×72
'80x80' Number of modules: 80×80
'88x88' Number of modules: 88×88
'96x96' Number of modules: 96×96
'104x104' Number of modules: 104×104
'120x120' Number of modules: 120×120
'132x132' Number of modules: 132×132
'144x144' Number of modules: 144×144
'8x18' Number of modules: 8×18
'8x32' Number of modules: 8×32
'12x26' Number of modules: 12×26
'12x36' Number of modules: 12×36
'16x36' Number of modules: 16×36
'16x48' Number of modules: 16×48
moduleSize

Specifies module size by the character string.
The valid value is from 2 to 16.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

Adds MaxiCode to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       maxiCodeMode: maxiCodeMode,
                       [alignment: alignment] } )

parameter

symbol

Specifies barcode symbol by the character string.
Specifies the character string 'maxicode'.
Cannot be omitted.

text

Specifies barcode data by the character string.
When maxiCodeMode is '2', add the service class (3 digits), the country code (3 digits), and the postal code (9 digits) at the beginning of the data.
When maxiCodeMode is '3', add the service class (3 digits), the country code (3 digits), and the postal code (6 digits) at the beginning of the data.maxiCodeMode.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
When maxiCodeMode is '2', add the service class (3 digits), the country code (3 digits), and the postal code (9 digits) at the beginning of the data.
When maxiCodeMode is '3', add the service class (3 digits), the country code (3 digits), and the postal code (6 digits) at the beginning of the data.maxiCodeMode.
Be sure to specify either the text or data element.

maxiCodeMode

Specifies MaxiCode mode by the character string. The valid value is any of '2', '3', '4', or '5'.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', ot 'right'.
Optional (default:'center').

Adds GS1 Databar Stacked to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       moduleSize: moduleSize,
                       [alignment: alignment] } )

Parameter

symbol

Specifies barcode symbol by the character string.
Specifies the character string 'gs1DatabarStacked'.
Cannot be omitted.

text

Specifies barcode data by the character string.
Input 13 characters from '0' to '9'.
The top of '01' is automatically added by the printer. Check digits are automatically calculated by the printer.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Input 13 characters from '0' to '9'.
The top of '01' is automatically added by the printer. Check digits are automatically calculated by the printer.
Be sure to specify either the text or data element.

moduleSize

Specifies module size by a numerical value.
The valid value is from 2 to 16.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

Addes GS1 Databar Stacked Omni-directional to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       moduleHeight: moduleHeight,
                       moduleSize: moduleSize,
                       [alignment: alignment] } )

Parameter

symbol

Specifies barcode symbol by the character string.
Specifies the character string 'gs1DatabarStackedOmniDirectional'.
Cannot be omitted.

text

Specifies barcode data by the character string.
Input 13 characters from '0' to '9'.
The top of '01' is automatically added by the printer. Check digits are automatically calculated by the printer.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Input 13 characters from '0' to '9'.
The top of '01' is automatically added by the printer. Check digits are automatically calculated by the printer.
Be sure to specify either the text or data element.

moduleHeight

Specifies the barcode module height (number of the modules) in numerical value.
The valid value is from 33 to 255.
Cannot be omitted.

moduleSize

Specifies module size by a numerical value.
The valid value is from 2 to 16.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

Adds GS1 Databar Expanded Stacked to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       column: column,
                       moduleSize: moduleSize,
                       [alignment: alignment] } )

Parameter

symbol

Specifies barcode symbol by the character string.
Specifies the character string 'gs1DatabarExpandedStacked'.
Cannot be omitted.

text

Specifies barcode data by the character string.
Input any number of characters using the following: ' ', '!', '"', '%', '&', ''', '('、')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '_', '0' to '9', 'A' to 'Z', 'a' to 'z'.
Input '{1’ to FNC1.
Be sure to input the check digit because it is not automatically calculated by the printer.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Be sure to input the check digit because it is not automatically calculated by the printer.
Be sure to specify either the text or data element.

column

Specifies the number of columns in 1 line by a numerical value.
Specify the number of columns in 1 line.
The valid value is the even number from 2 to 20.
Cannot be omitted.

moduleSize

Specifies module size by a numerical value.
The valid value is from 2 to 16.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

Adds Aztec Code to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       layer: layer,
                       errorCorrection: errorCorrection,
                       moduleSize: moduleSize,
                       aztecSymbol: aztecSymbol,
                       [alignment: alignment] } )

Parameter

symbol

Specifies barcode symbol by the character string.
Specify the character string 'aztecCode'.
Cannot be omitted.

text

Specifies barcode data by the character string.
Encode the data into binary in UTF-8 and add it to the buffer.
If the data to be sent cannot be specified as the character string, it can be specified with the following escape sequence.
Be sure to specify either the text or data element.

escape sequence description
\u00nn Control code(nn is specified in hexadecimal)
\ Backslash

To specify FNC1, input "\u001b\u0030" in the data. To specify 1Bh, input "\u001b\u001b" in the data.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Be sure to specify either the text or data element.

layer

Number of layer.
The valid value for full range mode is 0, 4 to 32.
The valid value for compact mode is 0, 1 to 4.
If 0 is specified, the layer is automatically set.
Cannot be omitted.

errorCorrection

Specifies the error correction level (%) by the character string.
The valid value is 0, 5 to 95.
If 0 is specified, the value is 23%.
Cannot be omitted.

moduleSize

Specifies module size by a numerical value.
The valid value is from 2 to 16.
Cannot be omitted.

aztecSymbol

Specifies Aztec by the character string.
The valid value is either 'fullRange' or 'compact'.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

Whether or not to be enable to print Aztec Code depends on the printer.

Printer Print Aztec Code
RP-F10 Not supported
MP-A40 Not supported
MP-B20 Not supported
MP-B21L Supported
MP-B30 Not supported
MP-B30L Supported
SLP720RT/721RT Not supported

Adds Customer Barcode to the buffer.

Syntax

async appendBarcode( { symbol: symbol,
                       [text: text,]
                       [data: data,]
                       moduleSize: moduleSize,
                       [alignment: alignment] } )

Parameter

symbol

Specifies alignment by the character string.
Specify the character string 'customerBarcodeJp'.
Cannot be omitted.

text

Specifies a barcode data by the character string. Some barcode symbols are converted to the code page specified by setCodePage and added to the buffer.
Be sure to specify either the text or data element.

data

Specifies barcode data by blob. The specified data is added to the buffer as is.
See the thermal printer technical reference for the data formats.
Be sure to specify either the text or data element.

moduleSize

Specifies the width of the barcode as a numerical value.
Specify a value from 4 to 10.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

Whether or not the customer barcode can be printed depends on the printer.

Printer Customer Barcode Print
RP-F10 Not supported
MP-A40 Not supported
MP-B20 Not supported
MP-B21L Supported
MP-B30 Not supported
MP-B30L Not supported
SLP720RT/721RT Not supported

appendBinary

Adds binary data to the buffer.

Syntax

async appendBinary( { data: data } )

Parameter

data

Specifies binary data by blob.
The data size that can be specified at 1 time is 16KB (16384 bytes).
Note that the data is converted to Base64 format before transmission. Therefore, the maximum size of binary data that can actually be specified is 12KB (12288 bytes).
Cannot be omitted.

Description

This method adds the specified binary data to the buffer without conversion.
By sending printer commands as binary data by this method, printer functions not supported by the library can be used. However, this method does not support commands to get a response from the printer.
A single printer command cannot be sent to a printer in multiple times with doPrint.

appendImage

Adds the specified image to the buffer.

Syntax

async appendImage( { format: format,
                     data: data,
                     [ alignment: alignment] } )

Parameter

format

Specifies the format of the image data by the character string.
The valid value is any of 'jpeg', 'png', or 'bmp'.
Cannot be omitted.

data

Specifies image data by bolb.
The valid size of the image data that can be specified is 3 MB (3145728 bytes).
Specifies the image data in the format specified in the format. If a color image is specified, converted to a monochrome image.
Cannot be omitted.

alignment

Specifies alignment by the character string.
The valid value is any of 'left', 'center', or 'right'.
Optional (default:'center').

appendCut

For the printer with auto cutter, adds the request of paper cut to the buffer. For the printer without auto cutter, adds the request of paper feed to the paper cut position to the buffer. The paper cut is not executed.

Syntax

async appendCut( { [ cuttingMethod: cuttingMethod ] } )

Parameter

cuttingMethod

Specifies cutting meyhod by the character string.
The valid value is any of 'full', 'fullNoFeed', 'partial', or 'partialNoFeed'.
Optional (default:'full').

appendFeed

Adds the paper feed request to the buffer.

Syntax

async appendFeed( { value: value } )

Parameter

value

Specifies the paper feed amount by a numerical value.
The valid value depends on the printer. See the table below.
Cannot be omitted.

Printer Range of feed value
RP-F10 -60 to 8000
MP-A40 -48 to 8000
MP-B20 0 to 8000
MP-B21L -28 to 8000
MP-B30 0 to 8000
MP-B30L 0 to 8000
SLP720RT/721RT -68 to 8000

appendMarkFeed

Adds the paper form feed request for marked paper or label to the buffer.

Syntax

async appendMarkFeed( { [ feedPosition: feedPosition ] } )

Parameter

feedPosition

Specifies the paper form feed position by the character string.
The valid value is either of 'cutPosition' or 'printPosition'.
Optional ('cutPosition').

feedPosition Description
cutPosition Feeds the paper to the cutting position after detecting the mark or gap.
printPosition Feeds the paper to the printing position after detecting the next mark or next gap.

Reference

  • The paper form feed is not performed even if this method is executed at the form feed position of the marked paper or label.

Whether or not to be enable to perform the paper form feed for the marked paper or label depends on the printer.
In addition, set the mark mode to enable in the memory switch settings of the printer beforehand when performing the paper form feed of marked paper or label.

Printer Paper Form Feed of Marked Paper or Label
RP-F10 Not Supported
MP-A40 Supported
MP-B20 Not Supported
MP-B21L Supported
MP-B30/B30L Supported
SLP720RT/721RT Supported

appendDrawer

Adds a request for opening a specified cash drawer to the buffer.

Syntax

async appendDrawer( { drawerNum: drawerNum,
                      onTime: onTime } )

Parameter

drawerNum

Specifies the drawer number by the character string.
The valid value is either of '1', or '2'.
Cannot be omitted.

onTime

Specifies pulse width (millisecond: ms) by a numerical value.
The valid value is from 100 to 800. The last 2 digits are ignored.
Cannot be omitted.

Whether or not to be enable to perform the open cash drawer depends on the printer.

Printer Open Cash Drawer
RP-F10 Supported
MP-A40 Not Supported
MP-B20 Not Supported
MP-B21L Not Supported
MP-B30/B30L Not Supported
SLP720RT Not Supported
SLP721RT Supported

appendBuzzer

Adds a request for a buzzer sound to the buffer.

Syntax

async appendBuzzer( { buzzerPattern: buzzerPattern,
                      buzzerCount: buzzerCount } )

Parameter

buzzerPattern

Specifies the buzzer pattern by a numerical value.
The valid value is from 1 to 4.
The external buzzer sound stops under any of the following conditions:
・Buzzer sounds for the number of times set by buzzerCount
・Opening the cover
・Executing the printer command "Stop External Buzzer"
Cannot be omitted.

buzzerCount

Specifies the sound frequency (times) by a numerical value.
Sounds an external buzzer for the number of times set by buzzerCount.
The valid value is 1 to 255.
Cannot be omitted.

Whether or not to be enable to perform the buzzer sound depends on the printer.
When performing the buzzer sound, connect an external buzzer.

Printer Buzzer Sound
RP-F10 Supported
MP-A40 Not Supported
MP-B20 Not Supported
MP-B21L Not Supported
MP-B30/B30L Not Supported
SLP720RT Not Supported
SLP721RT Supported

onDeviceStatus

Specifies or cancels the callback to be executed when the printer status changes.
When canceling, specify NULL.
While a callback is specified by onDeviceStatus, no other host can send to the printer or obtain printer status.
Exceptions occurred during the callback call are ignored.

Syntax

 onDeviceStatus = function( object )

Description

Returns an object containing the following elements when the printer's state changes.
For those with a value in "Priority", executes the callback only for the higher priority state.

'type' 'status' priority Description
'error' 'communication error' - Communication error (when unable to connect to the printer such as 26100 connection)
'error' 'timeout error' - Timrout error
'error' 'hardware error' 1 Hardware error
'error' 'battery error' 2 Battery error
'error' 'head temperature error' 3 Head temperature error
'error' 'voltage error' 4 Voltage error
'error' 'cutter error' 5 Cutter error
'error' 'cover open error' 6 Cover open error
'error' 'paper jam error' 7 Paper jam error while detecting mark(MP-B30L:Mark/Paper jam error while detecting gap)
'error' 'out-of-paper error' 8 Out-of-paper error
'info' 'print-ready' 9 Print-ready status
'info' 'printing finished' - Detects end of printing
'info' 'paper removal waiting' - Taken sensor status (Paper removal waiting)
'info' 'drawer open' - Open drawer
'info' 'drawer close' - Close drawer

doReset

Resets the printer.

Syntax

async doReset( {} )

Parameter

None

Specify an empty object.

Description

Resets the printer.

setInternationalCharacter

Sets international character set.

Syntax

async setInternationalCharacter( { internationalCharacter: internationalCharacter } )

Parameter

internationalCharacter

Specifies the international character set by the character string.
The valid values, see below.
Cannot be omitted.

internationalCharacter Description
'usa' USA
'france' France
'germany' Germany
'england' United Kingdom
'denmark1' Denmark I
'sweden' Sweden
'italy' Italy
'spain' Spain I
'japan' Japan
'norway' Norway
'denmark2' Denmark II
'spain2' Spain II
'latinAmerica' Latin America
'arabia' Arabia

Description

If the international character set is not set in this method, the international character set is as follows according to the language setting of the OS.

  • When the language setting of the OS device is Japanese: 'japan'
  • When the language setting of the OS device is other than Japanese: 'usa'

setCodePage

Sets cord page.

Syntax

async setCodePage( { codePage: codePage } )

Parameter

codePage

Specifies codepage constants as the character string.
The valid values, see below.
Cannot be omitted.

codePage Description
'437' USA, Standard Europe(Code Page437)
'katakana' Katakana
'850' Multilingual(Code Page850)
'860' Portuguese(Code Page860)
'863' Canadian-French(Code Page863)
'865' Nordic(Code Page865)
'857' Turkish(Code Page857)
'737' Greek(Code Page737)
'1252' Latin(Code Page1252)
'866' Russian(Code Page866)
'852' Eastern Europe(Code Page852)
'858' Euro(Code Page858)
'855' Cyrillic(Code Page855)
'864' Arabic(Code Page864)
'1250' Central European(Code Page1250)
'1251' Cyrillic(Code Page1251)
'1253' Greek(Code Page1253)
'1254' Turkish(Code Page1254)

Description

When this property is not set, it is initialized to following codepage depending on a language setting of an iOS device.

  • When a language setting of an iOS device is Japanese: 'katakana'
  • When a language setting of an iOS device is other languages than Japanese: '1252'

getVersion

Gets the SDK version as the character string.

Syntax

async getVersion( { } )

Parameter

None

Specify an empty object.

Return value

Returns the result object containing the following elements.

version

SDK version string (e.g., if the SDK server version is Ver. 1.0.0 and the SDK version is Ver. 1.0.1, the return value is '1.0.0/1.0.1')

Error Code

Error Code Discription
0 Success
-21 Failed to connect to printer.
-24 No printer is selected.
-111 An error occurred in the encoding of the property.
-201 Print timed out.
-202 Aborted during data conversion.
-203 The 'start' function needs to be called.
-299 Failed to parse response from Web SDK server.
-299 Failed to parse request from Web SDK.
-311 Failed to allocate memory.
-420 Printer error occurred.
-503 An error occurred during the data conversion.
-601 Unable to connect to Web SDK server.
-602 The Web SDK server does not support this SDK version.
Web SDK does not support this version of Web SDK Server.
-604 Web SDK server is busy.
-605 Communication with the SDK server is not connected.
Failed to reconnect to Web SDK server. Accessed from another web page while the connection to the Web SDK server was disconnected.
-9999 The object is not specified in the method argumen.
No property.
Invalid property type.
Invalid property value.
Unknown property was specified.