star-micronics / react-native-star-io10

react-native-star-io10 is a library for supporting application development for Star Micronics devices.
Other
90 stars 55 forks source link

Is there a method to open the cash drawer ? #23

Closed piyasil closed 3 years ago

piyasil commented 3 years ago

I can only find the property of drawer status.

piyasil commented 3 years ago

Found it. https://www.star-m.jp/products/s_print/sdk/react-native-star-io10/manual/en/api-reference/star-xpand-command/index.html

phuongna-comartek commented 2 years ago

@piyasil can you share the a code snippet for open the drawer, I tried many ways with the StarXandCompandBuilder and DrawerBuilder classes but no luck so far :(

yuliya9 commented 2 years ago

@phuongna-comartek This works for me:

const settings = new StarConnectionSettings()
settings.interfaceType = InterfaceType.Usb
const builder = new StarXpandCommand.StarXpandCommandBuilder()
builder.addDocument(new StarXpandCommand.DocumentBuilder()
  .addDrawer(new StarXpandCommand.DrawerBuilder().actionOpen(new OpenParameter())))
const printer = new StarPrinter(settings)
const commands = await builder.getCommands()
await printer.open()
await printer.print(commands)
await printer?.close()
await printer?.dispose()