Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

StarPRNT

Improve this doc

Repo: https://github.com/auctifera-josed/starprnt

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-starprnt
    $ npm install --save @ionic-native/star-prnt@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { StarPRNT } from '@ionic-native/star-prnt';


constructor(private starprnt: StarPRNT) { }

...


this.starprnt.portDiscovery('all')
  .then((res: any) => console.log(res))
  .catch((error: any) => console.error(error));

Instance Members

Emulation

Constant for Emulation

Encoding

Constant for possible Encoding

CodePageType

CodePageType constants

InternationalType

Constant for possible InternationalType

FontStyleType

Constant for possible FontStyleType

CutPaperAction

Constant for possible CutPaperAction

BlackMarkType

Constant for possible BlackMarkType

AlignmentPosition

Constant for possible AlignmentPosition

LogoSize

Constant for possible LogoSize

BarcodeSymbology

Constant for possible BarcodeSymbology

BarcodeWidth

Constant for possible BarcodeWidth

QrCodeModel

Constant for possible QrCodeModel

QrCodeLevel

Constant for possible QrCodeLevel

BitmapConverterRotation

Constant for possible BitmapConverterRotation

portDiscovery(type)

Find available printers

Param Type Details
type string

Interface Type: All, LAN, Bluetooth, USB

Returns: Promise<Printers> Returns a promise that resolves with an array of printers

checkStatus(port, emulation)

Checks the status of the printer

Param Type Details
port string

Printer name i.e BT:StarMicronics

emulation string

StarPrinter Emulation type: "StarPRNT", "StarPRNTL", "StarLine", "StarGraphic", "EscPos", "EscPosMobile", "StarDotImpact"

Returns: Promise<PrinterStatus> Returns a promise that resolves with the PrinterStatus object

printRawText(port, emulation, printObj)

Prints plain text

Param Type Details
port string

Printer name i.e BT:StarMicronics. Send null to use a printer connected via StarIOExtManager using the connect() function

emulation string

StarPrinter Emulation type: "StarPRNT", "StarPRNTL", "StarLine", "StarGraphic", "EscPos", "EscPosMobile", "StarDotImpact"

printObj PrintObj

text:string, cutReceipt?:boolean, openCashDrawer?:boolean

Returns: Promise<any> Success! if printed correctly or error message string returned by the SDK.

printRasterReceipt(port, emulation, rasterObj)

Converts the text into a bitmap image and sends it to the printer

Param Type Details
port string

Printer name i.e BT:StarMicronics. Send null to use a printer connected via StarIOExtManager using the connect() function

emulation string

StarPrinter Emulation type: "StarPRNT", "StarPRNTL", "StarLine", "StarGraphic", "EscPos", "EscPosMobile", "StarDotImpact"

rasterObj RasterObj

text:string, cutReceipt?:boolean, openCashDrawer?:boolean, fontSize:number, paperWidth:number

Returns: Promise<any> Success! if printed correctly or error message string returned by the SDK.

printImage(port, emulation, imageObj)

Gets an image from a string URI and converts it to bitmap to send it to the printer

Param Type Details
port string

Printer name i.e BT:StarMicronics. Send null to use a printer connected via StarIOExtManager using the connect() function

emulation string

StarPrinter Emulation type: "StarPRNT", "StarPRNTL", "StarLine", "StarGraphic", "EscPos", "EscPosMobile", "StarDotImpact"

imageObj ImageObj

uri:string, paperWidth?:number, cutReceipt?:boolean, openCashDrawer?:boolean

Returns: Promise<any> Success! if printed correctly or error message string returned by the SDK.

openCashDrawer(port, emulation)

sends an appendPeripheral command to the printer for channels No1 and No2

Param Type Details
port string

Printer name i.e BT:StarMicronics. Send null to use a printer connected via StarIOExtManager using the connect() function

emulation string

StarPrinter Emulation type: "StarPRNT", "StarPRNTL", "StarLine", "StarGraphic", "EscPos", "EscPosMobile", "StarDotImpact"

Returns: Promise<any> Success! if opened or error message string returned by the SDK.

print(port, emulation, commandsArray)

Sends an Array of commands to the command buffer using the Android ICommandBuilderInterface or iOS ISCBBuilderInterface

Param Type Details
port string

Printer name i.e BT:StarMicronics. Send null to use a printer connected via StarIOExtManager using the connect() function

emulation string

StarPrinter Emulation type: "StarPRNT", "StarPRNTL", "StarLine", "StarGraphic", "EscPos", "EscPosMobile", "StarDotImpact"

commandsArray CommandsArray

each command in the array should be an instance of the PrintCommand object. Example [{append:"text"}, {"openCashDrawer: 1"}]

Returns: Promise<any> Success! if printed correctly or error message string returned by the SDK.

connect(port, emulation, hasBarcodeReader)

Allows you to connect to the printer, keep the connection alive and receive status updates through an observable

Param Type Details
port string

printer name i.e BT:StarMicronics.

emulation string

StarPrinter Emulation type: "StarPRNT", "StarPRNTL", "StarLine", "StarGraphic", "EscPos", "EscPosMobile", "StarDotImpact"

hasBarcodeReader boolean

Set to true if the device has a barcode reader (e.g. mPop)

Returns: Observable<any> Success! if connected or error message string returned by the SDK.

getStatus()

Returns an observable with the device status events. Only fires when a printer is connnected through the connect() function

Returns: Observable<any> dataType: printerOnline, printerOffline, printerImpossible, printerPaperEmpty, printerPaperNearEmpty, printerPaperReady, printerCoverOpen, printerCoverClose, cashDrawerOpen, cashDrawerClose

disconnect()

Allows to disconnect (close the connection to the peripherals), this is useful to avoid keeping alive a connection when not in the app to save device battery (energy consumption). You should call this function when the app is paused or closed.

Returns: Promise<any> Success! if connected or error message string returned by the SDK.

API

Native

General