ESC POS不打印全文?

时间:2018-02-20 14:38:57

标签: ios objective-c bluetooth escpos

我正在使用ESC-POS打印系统,我可以使用下面的代码打印消息,但它不打印整个文本。

NSMutableData* commandData = [[NSMutableData alloc] init];
[commandData appendBytes:"ESC" "@" length:0];
[commandData appendBytes:"ESC" "!" "0" length:0];
[commandData appendBytes:"ESC" "d" "20" length:0];

NSString *text = @"\nUnderline exceptions\n- Does not underline 90°/270° rotation\n- Does not underline horizontal tabs\n- Underline thickness";
NSData* data = [text dataUsingEncoding:NSUTF8StringEncoding];
[commandData appendData:data];

NSString *text1 = @"\nThis command resets the left and right margins\n- Left margin set by :ref:`Left Margin<1d4c>`\n- Right margin set by :ref:`Print Area Width<1d57>`\nFor each of the underline, italic, bold modes:\n- These can be issued by their respective ESC commands or this command\n- The last received command is the effective command.;\nThis command resets the left and right margins\n- Left margin set by :ref:`Left Margin<1d4c>`\n- Right margin set by :ref:`Print Area Width<1d57>`\nFor each of the underline, italic, bold modes:\n- These can be issued by their respective ESC commands or this command\n- The last received command is the effective command.;";
NSData* data1 = [text1 dataUsingEncoding:NSUTF8StringEncoding];
[commandData appendData:data1];

const void* sendBuffer = (unsigned char*)[commandData bytes];
NSUInteger sendLength =commandData.length;

if(sendLength==7){
    sendLength=7;//for Test
}

if (self.discoveredCharacteristic != nil){
    [self.discoveredPeripheral writeValue:[NSData dataWithBytes:sendBuffer length:sendLength] forCharacteristic:self.discoveredCharacteristic type:CBCharacteristicWriteWithResponse];
}

让我知道我在做错的地方。

提前致谢。

0 个答案:

没有答案