我正在尝试使用 Zebra QLn220 和 link_os_sdk 从 iOS 设备打印图像。图像为 719x1248 像素,但打印时总是会切掉一半图像。我通过 Zebra Setup Utilities 将打印机的标签尺寸设置为 1.8 英寸 x 4 英寸,这似乎打印出 3 英寸的空白标签和一小部分图像。我还尝试将图像缩放到原始大小的一半,但没有成功。我该怎么做才能让整个图像显示在标签上?
-(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);
}
}
}