繁体   English   中英

斑马打印机打印被裁切的图像

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM