Zebra SDK printing problem

// Expert user has replied.
D Dmitrij Burakov,30g78uf68ae0aa4wrzb4rc6em1jumq6q 3 years 7 months ago
2 1 0

Hi,

I have a problem with printing stability using QLn 320 Zebra with firmware V68.19.7Z from iOS application.
I use Zebra SDK and print code is:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {
        // Instantiate connection to Zebra Bluetooth accessory
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        NSString *serialNumber = [defaults valueForKey:@"selectedPrinterSN"];
        id thePrinterConn = [[MfiBtPrinterConnection alloc] initWithSerialNumber:serialNumber];
       
        BOOL success = [thePrinterConn open];
       
        NSString *zplData = [NSString stringWithFormat:
                             @"^XA" \
                             @"^LH20,20^POI" \
                             @"^FT5,5^FH^A0N,30,30^FD%@^FS" \
                             @"^FT5,45^FH^A0N,30,30^FD%@^FS" \
                             @"^XZ" \
                             , @“Line1”, @“Line2”];
       
        NSError *error = nil;
        NSMutableData *data = [[zplData dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];       
       
        long blockSize = 1024;
        long totalSize = data.length;
        long bytesRemaining = totalSize;
        while (bytesRemaining > 0) {
            long bytesToSend = MIN(blockSize, bytesRemaining);
            NSRange range = NSMakeRange(0, bytesToSend);
           
            NSData *partialLabel = [data subdataWithRange:range];
            [thePrinterConn write:partialLabel error:&error];
           
            bytesRemaining -= bytesToSend;
           
            [data replaceBytesInRange:range withBytes:NULL length:0];
            if (error) {
                break;
            }
        }

        [thePrinterConn close];
       
        dispatch_async(dispatch_get_main_queue(), ^{
              //Update UI on the main queue!
        });
    });

There is a button “Print Label” on UI that triggers label printing.
Sometimes label is not printed (about 1 label of 10 attempts) without any errors from MfiBtPrinterConnection.
I tried to change timeout but this didn’t help.
[((MfiBtPrinterConnection*)thePrinterConn) setTimeToWaitAfterWriteInMilliseconds:30];

Could you advice how to find the reason of that (get logs from printer or something different)?

Please Register or Login to post a reply

1 Replies

J Joydeep Chakraborty

Are you trying this in RhoMobileSuite or is this a IOS native application where you are trying to print with QLN320 printer?

CONTACT
Can’t find what you’re looking for?