Latest 1.2
Homepage https://github.com/relishapps/RMLStarReceiptPrinter
License MIT
Platforms ios 8.4, requires ARC
Frameworks CoreBluetooth
Authors

Build Status
Version
License
Platform

Introduction

A wrapper for StarIO SDK that makes printing receipts a breeze.

Features

  • Works with SM-S220i and similar
  • Support for 2 inch-wide paper
  • Text print with styling: emphasis, alignment, character expansion, various character sets

Installation

RMLStarReceiptPrinter is available through CocoaPods. To install it:

  1. Add the following line to your Podfile:

    pod "RMLStarReceiptPrinter"
  2. Run pod install.
  3. Open your Info.plist file and add the jp.star-m.starpro to Supported external accessory protocols.

To run the example project, clone the repo, and run pod install from the Example directory.

Usage

To use RMLStarReceiptPrinter in your existing project, once you’ve installed it, add #import "RMLStarReceiptPrinter.h" to the header file where you want to use it, and initialise it.

Initialise with default device (factory name):

RMLStarReceiptPrinter *printer = [RMLStarReceiptPrinter new];

Init with specific RMLStarReceiptPrinterDevice:

RMLStarReceiptPrinter *printer = [RMLStarReceiptPrinter printerWithDevice:device];

An NSArray of available devices can be fetched by:

NSArray *devices = [RMLStarReceiptPrinter availableDevices];

To send text to the print buffer:

[printer sendText:@"Hello, world!"];

And to send the buffer to the printer:

[printer print];

RMLStarReceiptPrinter Methods

init

- (instancetype)init;
Return Value

An instance of RMLStarReceiptPrinter.

Description

Used to initialize the printer instance with a default device (one with factory name).

initWithDevice

- (instancetype)initWithDevice:(RMLStarReceiptPrinterDevice*)device;
Parameters
device
instance of an RMLStarReceiptPrinterDevice object
Return Value

instance type of RMLStarReceiptPrinter

Description

Used to initialize the printer instance with a specific device

availableDevices

+ (NSArray *)availableDevices;
Return Value

An array of RMLStarReceiptPrinterDevice objects

Description

Searches both Bluetooth and LAN networks for available printing devices

print

- (BOOL)print;
Return Value

a bool value based on the success of the pritner printing the receipt

Description

The main method used to tell the printer to print the receipt

sendSeparator

- (void)sendSeparator;
Description

Sends a string of 32 hyphens (‘-‘) to the printer, followed by a line break to help separate items on the receipt.

sendText:

- (void)sendText:(NSString *)text;
Parameters
text

an NSString for the printer to print

Description

Used to send a single line of text to the printer to print.

WARNING:

Format the text before you use this method (i.e. send all emphasis and alignment before sendtext:)

setCharacterExpansion:

- (void)setCharacterExpansion:(RMLStarReceiptPrinterCharacterExpansion)expansion;
Parameters
expansion

one of the RMLStarReceiptPrinterCharacterExpansion options

Description

Used to set the size of the characters you send to the printer

setCharacterSet:

- (void)setCharacterSet:(RMLStarReceiptPrinterCharacterSet)characterSet;
Parameters
characterSet

RMLStarReceiptPrinterCharacterSet on the character set you want

Description

Set the character encoding set

setTextAlignment:

- (void)setTextAlignment:(RMLStarReceiptPrinterTextAlignment)alignment;
Parameters
alignment

The alignment that you want to set (as RMLStarReceiptPrinterTextAlignment)

Description

Adjust the alignment of the text on the receipt

setTextEmphasis:

- (void)setTextEmphasis:(RMLStarReceiptPrinterTextEmphasis)emphasis;
Parameters
emphasis

RMLStarReceiptPrinterTextEmphasisIsOff, RMLStarReceiptPrinterTextEmphasisIsOn

Description

Using the RMLStarReceiptPrinterTextEmphasis, you can set whether the following test is emphasised or not

starIOVersion

+ (NSString *)starIOVersion;
Return Value

an NSString value of the StarIO framework version number

Description

Returns the current version of the StarIO framework in use

status

- (RMLStarReceiptPrinterStatus)status;
Return Value

The printer’s current status (as RMLStarReceiptPrinterStatus)

Description

Returns the current status of the printer (Read-only)

RMLStarReceiptPrinterCharacterExpansion

typedef NS_ENUM(char, RMLStarReceiptPrinterCharacterExpansion){  
RMLStarReceiptPrinterCharacterExpansionNone = 0,  RMLStarReceiptPrinterCharacterExpansionSingleWidthDoubleHeight =
(
1 << 0)|( 0),  RMLStarReceiptPrinterCharacterExpansionDoubleWidthDoubleHeight =
(
1 << 0)|(
1 << 4) 
};
Constants
RMLStarReceiptPrinterCharacterExpansionNone

Resets to default width and height

RMLStarReceiptPrinterCharacterExpansionSingleWidthDoubleHeight

Makes characters double height, but maintains width

RMLStarReceiptPrinterCharacterExpansionDoubleWidthDoubleHeight

Makes characters double height and width

Description

An option for changing the height and/or width of the next charaters sent to the printer

RMLStarReceiptPrinterCharacterSet

typedef NS_ENUM(char, RMLStarReceiptPrinterCharacterSet){  
RMLStarReceiptPrinterCharacterSetUSA,  RMLStarReceiptPrinterCharacterSetFrance,  
RMLStarReceiptPrinterCharacterSetGermany,  RMLStarReceiptPrinterCharacterSetUK,  
RMLStarReceiptPrinterCharacterSetDenmark,  RMLStarReceiptPrinterCharacterSetSweden,  
RMLStarReceiptPrinterCharacterSetItaly,  RMLStarReceiptPrinterCharacterSetSpain,  
RMLStarReceiptPrinterCharacterSetJapan,  RMLStarReceiptPrinterCharacterSetNorway,  
RMLStarReceiptPrinterCharacterSetDenmark2 
};
Parameters
RMLStarReceiptPrinterCharacterSetUSA

USA character set

RMLStarReceiptPrinterCharacterSetFrance

France character set

RMLStarReceiptPrinterCharacterSetGermany

Germany character set

RMLStarReceiptPrinterCharacterSetUK

UK character set

RMLStarReceiptPrinterCharacterSetDenmark

Denmark character set

RMLStarReceiptPrinterCharacterSetSweden

Sweden character set

RMLStarReceiptPrinterCharacterSetItaly

Italy character set

RMLStarReceiptPrinterCharacterSetSpain

Spain character set

RMLStarReceiptPrinterCharacterSetJapan

Japan character set

RMLStarReceiptPrinterCharacterSetNorway

Norway character set

RMLStarReceiptPrinterCharacterSetDenmark2

Denmark 2 character set

Description

Values to set the character set of the next text sent to the printer to.

RMLStarReceiptPrinterStatus

typedef NS_ENUM(char, RMLStarReceiptPrinterStatus){  
RMLStarReceiptPrinterStatusOffline,  RMLStarReceiptPrinterStatusOfflineCoverOpen,  
RMLStarReceiptPrinterStatusOfflineOutOfPaper,  RMLStarReceiptPrinterStatusOnline,  
RMLStarReceiptPrinterStatusError 
};
Parameters

The printer is either powered off, or not connected to the device

RMLStarReceiptPrinterStatusOfflineCoverOpen

The printer cover is open

RMLStarReceiptPrinterStatusOfflineOutOfPaper

The printer is out of paper

RMLStarReceiptPrinterStatusOnline

The printer is online and ready to be used

RMLStarReceiptPrinterStatusError

The printer has an error

Description

The current status of the printer

RMLStarReceiptPrinterTextAlignment

typedef NS_ENUM(char, RMLStarReceiptPrinterTextAlignment){  
RMLStarReceiptPrinterTextAlignmentLeft = 0,  RMLStarReceiptPrinterTextAlignmentCenter = 
1,  RMLStarReceiptPrinterTextAlignmentRight = 2 
};
Constants
RMLStarReceiptPrinterTextAlignmentLeft

Left alignment

RMLStarReceiptPrinterTextAlignmentCenter

Center alignment

RMLStarReceiptPrinterTextAlignmentRight

Right alignment

Description

Values to set the alignment of next text sent to the printer.

RMLStarReceiptPrinterTextEmphasis

typedef NS_ENUM(char, RMLStarReceiptPrinterTextEmphasis){  
RMLStarReceiptPrinterTextEmphasisOff = 0,  RMLStarReceiptPrinterTextEmphasisOn = 
1 
};
Constants
RMLStarReceiptPrinterTextEmphasisOff

Turns off the emphasis

RMLStarReceiptPrinterTextEmphasisOn

Turns on the emphasis

Description

Equal to setting the text to bold.


RMLStarReceiptPrinterDevice Methods

defaultDevice

+ (RMLStarReceiptPrinterDevice*)defaultDevice;
Return Value

instance of RMLStarReceiptPrinterDevice with portName "BT:PRNT Star"

Description

A class method to return a device with portName "BT:PRNT Star"

initWithPortName:macAddess:modelName:

- (instancetype)initWithPortName:(NSString *)portName 
macAddess:(NSString *)macAddress modelName:(NSString *)modelName;
Parameters
portName

The full ‘portName’ for the device e.g. “BT:PRNT Star” (required)

macAddress

The MAC address (optional)

modelName

The model name (optional)

Return Value

instance of RMLStarReceiptPrinterDevice

Description

An init method to set all properties

RMLStarReceiptPrinterDevice properties

macAddress

@property NSString *macAddress;
Description

The MAC address of the device

modelName

@property NSString *modelName;
Description

The model name of the device

portName

@property NSString *portName;
Description

The ‘portName’ of the device e.g. "BT:PRNT Star"


Planned improvements

  • Various widths of paper
  • Image printing

Authors

License

RMLStarReceiptPrinter is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "RMLStarReceiptPrinter",
    "version": "1.2",
    "summary": "Wrapper for StarIO SDK",
    "description": "RMLStarReceiptPrinter makes printing receipts a breeze!",
    "homepage": "https://github.com/relishapps/RMLStarReceiptPrinter",
    "license": "MIT",
    "authors": {
        "Pawel Decowski": "[email protected]"
    },
    "source": {
        "git": "https://github.com/relishapps/RMLStarReceiptPrinter.git",
        "tag": "v1.2"
    },
    "social_media_url": "https://twitter.com/relishmedia",
    "platforms": {
        "ios": "8.4"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "frameworks": "CoreBluetooth",
    "vendored_frameworks": [
        "Pod/Frameworks/StarIO.framework",
        "Pod/Frameworks/StarIO_Extension.framework"
    ],
    "public_header_files": "Pod/Classes/*.h"
}

Pin It on Pinterest

Share This