Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions src/ios/StarPRNT.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ -(void)printRawText:(CDVInvokedUrlCommand *)command {
NSString *portName = nil;
NSString *emulation = nil;
NSDictionary *printObj = nil;


if (command.arguments.count > 0) {
portName = [command.arguments objectAtIndex:0];
Expand All @@ -143,11 +142,10 @@ -(void)printRawText:(CDVInvokedUrlCommand *)command {

NSString *portSettings = [self getPortSettingsOption:emulation];
NSString *text = [printObj valueForKey:@"text"];
BOOL cutReceipt = ([printObj valueForKey:@"cutReceipt"]) ? YES : NO;
BOOL openCashDrawer = ([printObj valueForKey:@"openCashDrawer"]) ? YES : NO;
BOOL cutReceipt = ([[printObj objectForKey:@"cutReceipt"]boolValue]) ? YES : NO;
BOOL openCashDrawer = ([[printObj objectForKey:@"openCashDrawer"]boolValue]) ? YES : NO;
StarIoExtEmulation Emulation = [self getEmulation:emulation];


ISCBBuilder *builder = [StarIoExt createCommandBuilder:Emulation];

[builder beginDocument];
Expand Down Expand Up @@ -188,7 +186,6 @@ -(void)printBase64Image:(CDVInvokedUrlCommand *)command {
NSString *portName = nil;
NSString *emulation = nil;
NSDictionary *printObj = nil;


if (command.arguments.count > 0) {
portName = [command.arguments objectAtIndex:0];
Expand All @@ -199,8 +196,8 @@ -(void)printBase64Image:(CDVInvokedUrlCommand *)command {
NSString *portSettings = [self getPortSettingsOption:emulation];
NSString *base64Image = [printObj valueForKey:@"base64Image"];
CGFloat width = ([printObj valueForKey:@"width"]) ? [[printObj valueForKey:@"width"] floatValue] : 576;
BOOL cutReceipt = ([printObj valueForKey:@"cutReceipt"]) ? YES : NO;
BOOL openCashDrawer = ([printObj valueForKey:@"openCashDrawer"]) ? YES : NO;
BOOL cutReceipt = ([[printObj objectForKey:@"cutReceipt"]boolValue]) ? YES : NO;
BOOL openCashDrawer = ([[printObj objectForKey:@"openCashDrawer"]boolValue]) ? YES : NO;
StarIoExtEmulation Emulation = [self getEmulation:emulation];

NSData *data = [[NSData alloc] initWithBase64EncodedString:base64Image options:0];
Expand Down Expand Up @@ -246,7 +243,6 @@ -(void)printRasterReceipt:(CDVInvokedUrlCommand *)command {
NSString *emulation = nil;
NSDictionary *printObj = nil;


if (command.arguments.count > 0) {
portName = [command.arguments objectAtIndex:0];
emulation = [command.arguments objectAtIndex:1];
Expand All @@ -257,8 +253,8 @@ -(void)printRasterReceipt:(CDVInvokedUrlCommand *)command {
NSString *text = [printObj valueForKey:@"text"];
NSInteger fontSize = ([printObj valueForKey:@"fontSize"]) ? [[printObj valueForKey:@"fontSize"] intValue] : 25;
CGFloat paperWidth = ([printObj valueForKey:@"paperWidth"]) ? [[printObj valueForKey:@"paperWidth"] floatValue] : 576;
BOOL cutReceipt = ([printObj valueForKey:@"cutReceipt"]) ? YES : NO;
BOOL openCashDrawer = ([printObj valueForKey:@"openCashDrawer"]) ? YES : NO;
BOOL cutReceipt = ([[printObj objectForKey:@"cutReceipt"]boolValue]) ? YES : NO;
BOOL openCashDrawer = ([[printObj objectForKey:@"openCashDrawer"]boolValue]) ? YES : NO;
StarIoExtEmulation Emulation = [self getEmulation:emulation];

UIFont *font = [UIFont fontWithName:@"Menlo" size:fontSize];
Expand All @@ -269,7 +265,7 @@ -(void)printRasterReceipt:(CDVInvokedUrlCommand *)command {

[builder beginDocument];

[builder appendBitmap:image diffusion:NO];
[builder appendBitmap:image diffusion:NO];

if(cutReceipt == YES){
[builder appendCutPaper:SCBCutPaperActionPartialCutWithFeed];
Expand All @@ -295,7 +291,6 @@ -(void)printRasterReceipt:(CDVInvokedUrlCommand *)command {
callbackId:command.callbackId];

}

}];
}

Expand All @@ -315,8 +310,8 @@ -(void)printRasterData:(CDVInvokedUrlCommand *)command { //print image
NSString *portSettings = [self getPortSettingsOption:emulation];
NSString *uri = [printObj valueForKey:@"uri"];
CGFloat paperWidth = ([printObj valueForKey:@"paperWidth"]) ? [[printObj valueForKey:@"paperWidth"] floatValue] : 576;
BOOL cutReceipt = ([printObj valueForKey:@"cutReceipt"]) ? YES : NO;
BOOL openCashDrawer = ([printObj valueForKey:@"openCashDrawer"]) ? YES : NO;
BOOL cutReceipt = ([[printObj objectForKey:@"cutReceipt"]boolValue]) ? YES : NO;
BOOL openCashDrawer = ([[printObj objectForKey:@"openCashDrawer"]boolValue]) ? YES : NO;
StarIoExtEmulation Emulation = [self getEmulation:emulation];

NSURL *imageURL = [NSURL URLWithString:uri];
Expand Down Expand Up @@ -496,7 +491,6 @@ - (void)printRawData:(CDVInvokedUrlCommand *)command {

ISCBBuilder *builder = [StarIoExt createCommandBuilder:Emulation];


[builder appendData:[content dataUsingEncoding:NSWindowsCP1252StringEncoding]];

[self sendCommand:[builder.commands copy] callbackId:command.callbackId];
Expand Down Expand Up @@ -542,7 +536,6 @@ - (void)printReceipt:(CDVInvokedUrlCommand *)command {
NSStringEncoding encoding = NSWindowsCP1252StringEncoding;
NSString *content = nil;
ISCBBuilder *builder = [StarIoExt createCommandBuilder:StarIoExtEmulationStarLine];


if (command.arguments.count > 0) {
content = [command.arguments objectAtIndex:0];
Expand Down Expand Up @@ -898,13 +891,13 @@ -(void)didCashDrawerOpen {
[self sendData:@"cashDrawerOpen" data:nil];
}];
}

-(void)didCashDrawerClose {
[self.commandDelegate runInBackground:^{
[self sendData:@"cashDrawerClose" data:nil];
}];
}


-(void)didBarcodeReaderImpossible {
[self.commandDelegate runInBackground:^{
[self sendData:@"barcodeReaderImpossible" data:nil];
Expand All @@ -923,7 +916,7 @@ -(void)didBarcodeReaderDisconnect {
}];
}

- (void)didBarcodeDataReceive:(NSData *)data {
-(void)didBarcodeDataReceive:(NSData *)data {
[self.commandDelegate runInBackground:^{
NSMutableString *text = [NSMutableString stringWithString:@""];
const uint8_t *p = [data bytes];
Expand Down