我正在使用 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];
}
让我知道我在哪里做错了。
提前致谢。