[英]Zebra Printer Prints images that are cut off
我正在嘗試使用Zebra QLn220和link_os_sdk從iOS設備打印圖像。 圖像為719x1248像素,但是打印時圖像的一半總是被剪切掉。 我已通過Zebra設置實用程序將打印機的標簽尺寸設置為1.8英寸乘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);
}
}
}
只需在此處進行更改,就可以解決整個圖像在標簽上顯示的問題。 默認比例為2.0。 我們需要根據需要進行更改。
UIGraphicsBeginImageContextWithOptions(rect.size,NO,self.view.window.screen.scale + 0.75); 之后,比例為2.75
試試這個可能對您有幫助。 因為,我曾經遇到過同樣的問題,所以只需添加此問題即可解決我的問題。 請享用!
QLn220是一台2英寸打印機@ 200dpi,這意味着您可以得到的最大寬度約為400點。嘗試在打印之前將打印圖像線更改為這樣的尺寸以縮放圖像
success = success && [[self.printer getGraphicsUtil] printImageFromFile:filePath atX:0 atY:0 withWidth:300 withHeight:500 andIsInsideFormat:NO error:&error];
它可能是失真的圖像,但不應切斷
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.