https://github.com/willpowell8/ktstarreceiptprinter
https://github.com/willpowell8/ktstarreceiptprinter
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/willpowell8/ktstarreceiptprinter
- Owner: willpowell8
- License: mit
- Created: 2019-02-14T03:54:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-14T03:57:28.000Z (over 7 years ago)
- Last Synced: 2025-01-05T06:28:35.070Z (over 1 year ago)
- Language: Objective-C
- Size: 16.9 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RMLStarReceiptPrinter
[](https://travis-ci.org/relishapps/RMLStarReceiptPrinter)
[](http://cocoapods.org/pods/RMLStarReceiptPrinter)
[](http://cocoapods.org/pods/RMLStarReceiptPrinter)
[](http://cocoapods.org/pods/RMLStarReceiptPrinter)
## 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](http://cocoapods.org). To install it:
1. Add the following line to your Podfile:
```objective-c
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):
```objective-c
RMLStarReceiptPrinter *printer = [RMLStarReceiptPrinter new];
```
Init with specific RMLStarReceiptPrinterDevice:
```objective-c
RMLStarReceiptPrinter *printer = [RMLStarReceiptPrinter printerWithDevice:device];
```
An `NSArray` of available devices can be fetched by:
```objective-c
NSArray *devices = [RMLStarReceiptPrinter availableDevices];
```
To send text to the print buffer:
```objective-c
[printer sendText:@"Hello, world!"];
```
And to send the buffer to the printer:
```objective-c
[printer print];
```
## RMLStarReceiptPrinter Methods
### init
```objective-c
- (instancetype)init;
```
##### Return Value
An instance of RMLStarReceiptPrinter.
##### Description
Used to initialize the printer instance with a default device (one with factory name).
### initWithDevice
```objective-c
- (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
```objective-c
+ (NSArray *)availableDevices;
```
##### Return Value
An array of RMLStarReceiptPrinterDevice objects
##### Description
Searches both Bluetooth and LAN networks for available printing devices
```objective-c
- (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
```objective-c
- (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:
```objective-c
- (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:
```objective-c
- (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:
```objective-c
- (void)setCharacterSet:(RMLStarReceiptPrinterCharacterSet)characterSet;
```
##### Parameters
- characterSet
-
RMLStarReceiptPrinterCharacterSet on the character set you want
##### Description
Set the character encoding set
### setTextAlignment:
```objective-c
- (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:
```objective-c
- (void)setTextEmphasis:(RMLStarReceiptPrinterTextEmphasis)emphasis;
```
##### Parameters
- emphasis
-
RMLStarReceiptPrinterTextEmphasisIsOff, RMLStarReceiptPrinterTextEmphasisIsOn
##### Description
Using the RMLStarReceiptPrinterTextEmphasis, you can set whether the following test is emphasised or not
### starIOVersion
```objective-c
+ (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
```objective-c
- (RMLStarReceiptPrinterStatus)status;
```
##### Return Value
The printer's current status (as RMLStarReceiptPrinterStatus)
##### Description
Returns the current status of the printer (Read-only)
### RMLStarReceiptPrinterCharacterExpansion
```objective-c
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
```objective-c
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
```objective-c
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
```objective-c
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
```objective-c
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
```objective-c
+ (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:
```objective-c
- (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
```objective-c
@property NSString *macAddress;
```
##### Description
The MAC address of the device
### modelName
```objective-c
@property NSString *modelName;
```
##### Description
The model name of the device
### portName
```objective-c
@property NSString *portName;
```
##### Description
The 'portName' of the device e.g. "BT:PRNT Star"
* * *
## Planned improvements
- Various widths of paper
- Image printing
## Authors
- Pawel Decowski: pawel@relish.io
- Dan Sinclair: dan@relish.io
## License
RMLStarReceiptPrinter is available under the MIT license. See the LICENSE file for more info.