2017-05-26 2 views
0

J'utilise l'imprimante Zebra iMZ320. J'essaie d'imprimer une image PNG à travers l'application Zebra Utilities à partir d'un appareil Android. Y at-il un moyen d'ajuster la longueur de l'alimentation pour correspondre à la hauteur de l'image sans l'étirement de l'image? À l'heure actuelle, la seule commande que j'ai envoyé à l'imprimante à l'aide de l'utilitaire de configuration Zebra est:Comment régler la longueur d'alimentation pour qu'elle corresponde à la hauteur de l'image sur l'imprimante Zebra iMZ320

! U1 "ezpl.media_type" "continuous" ! U1 "ezpl.print_mode" "tear off"

Répondre

0

Il est par exemple complet (Objective-C) d'impression UIImage, en utilisant ZEBRA iMZ320. Je pense, vous pouvez utiliser les mêmes commandes d'impression et préparer le code approprié en Java ou Kotlin:

UIImage *image = ...; //printing image; default wight should be ~572 
    id<ZebraPrinterConnection, NSObject> connection = [[MfiBtPrinterConnection alloc] initWithSerialNumber:serialNumber]; 
    if (![connection open]) { 
     NSLog(@"Printer Error! Please check the printer and try it again."); 
     return; 
    } 
    NSError *error = nil; 
    id<ZebraPrinter, NSObject> printer = [ZebraPrinterFactory getInstance:connection error:&error]; 
    PrinterStatus *status = [printer getCurrentStatus:&error]; 
    if (status == nil) { 
     NSLog(@"Error: %@", [error localizedDescription]); 
     return; 
    } else if (!status.isReadyToPrint) { 
     NSLog(@"The printor is not ready to print"); 
     return; 
    } 
    CGSize imageSize = image.size; 
    //Send configuration command with setting "media_type" = "continuous" and "printing height" = "imageSize.height" 
    for (NSString *cmd in @[@"! U1 setvar \"ezpl.media_type\" \"continuous\"\r\n", 
          [NSString stringWithFormat:@"! U1 setvar \"zpl.label_length\" \"%d\"\r\n", (int)imageSize.height]]) { 
     if (![[printer getToolsUtil] sendCommand:cmd error:&error]) { 
      NSLog(error == nil ? @"Printer Error! Please check the printer and try it again." : [error localizedDescription])); 
      return; 
     } 
    } 
    [NSThread sleepForTimeInterval:1]; 
    if ([[printer getGraphicsUtil] printImage:[image CGImage] atX:0 atY:0 withWidth:-1 withHeight:-1 andIsInsideFormat:false error:&error]) { 
     status = [printer getCurrentStatus:&error]; 
     int i = 0; 
     while (!status.isReadyToPrint || i > 30) { 
      [NSThread sleepForTimeInterval:1]; 
      status = [printer getCurrentStatus:&error]; 
      i++; 
     } 
     [NSThread sleepForTimeInterval:1]; 
     NSLog(@"Prining should be success"); 
    } else { 
     NSLog(error == nil ? @"Printer Error! Please check the printer and try it again." : [error localizedDescription])); 
    } 
    for (NSString *cmd in @[[NSString stringWithFormat:@"! U1 setvar \"zpl.label_length\" \"%d\"\r\n", 50], 
          @"PRINT\r\n"]) { 
     [[printer getToolsUtil] sendCommand:cmd error:nil]; 
    } 
    [connection close];