Search code examples
iosobjective-czebra-printers

Zebra Printer Prints images that are cut off


I'm attempting to print images from iOS devices with a Zebra QLn220 and the link_os_sdk. The image is 719x1248 pixels, but half of the image is always cut off when printed. I've set the printer's label size to 1.8in by 4in via Zebra Setup Utilities, which appears to print out 3 inches of blank label and a small section of the image. I've also tried scaling the image to half it's original size with no luck. What can I do to get the entire image to display on the label?

-(void)printImageButtonTapped : (DiscoveredPrinter *)discoveredPrinter {
    NSString* filePath = [[NSBundle mainBundle] pathForResource:@"jpegsample"
                                                         ofType:@"jpeg"];
    self.connection = [[TcpPrinterConnection alloc] initWithAddress:discoveredPrinter.address andWithPort:6101];
    NSError *error = nil;
    [self.connection open];
    self.printer = [ZebraPrinterFactory getInstance:self.connection error:&error];
    if(error != nil) {
        NSLog(@"Error: %@",error);
    }
    error = nil;
    if (self.printer != nil) {
        TcpPrinterConnection *zebraPrinterConnection = [[TcpPrinterConnection alloc] initWithAddress:discoveredPrinter.address andWithPort:6101];
        BOOL success = [zebraPrinterConnection open];
        success = success && [[self.printer getGraphicsUtil] printImageFromFile:filePath atX:0 atY:0 withWidth:-1 withHeight:-1 andIsInsideFormat:NO error:&error];
        [zebraPrinterConnection close];
        if (error != nil || self.printer == nil || success == NO) {
            NSLog(@"error: %@ printer: %@ success: %hhd",error,self.printer,success);
        }
    }
}

Solution

  • The QLn220 is a 2" printer @ 200dpi, so that means the max width you can get is about 400 dots. Try changing your print image line to something like this to scale the image before printing

    success = success && [[self.printer getGraphicsUtil] printImageFromFile:filePath atX:0 atY:0 withWidth:300 withHeight:500 andIsInsideFormat:NO error:&error];
    

    It might be a distorted image, but it shouldn't cut off