简体   繁体   English

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

[英]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. 我正在尝试使用Zebra QLn220和link_os_sdk从iOS设备打印图像。 The image is 719x1248 pixels, but half of the image is always cut off when printed. 图像为719x1248像素,但是打印时图像的一半总是被剪切掉。 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. 我已通过Zebra设置实用程序将打印机的标签尺寸设置为1.8英寸乘4英寸,该尺寸似乎可以打印出3英寸的空白标签和一小部分图像。 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);
        }
    }
}

Just do change here, it will solve ur problem for entire image to display on the label. 只需在此处进行更改,就可以解决整个图像在标签上显示的问题。 default scale is 2.0. 默认比例为2.0。 we need to change as per we need. 我们需要根据需要进行更改。

UIGraphicsBeginImageContextWithOptions(rect.size, NO, self.view.window.screen.scale+0.75); UIGraphicsBeginImageContextWithOptions(rect.size,NO,self.view.window.screen.scale + 0.75); after doing this - scale is 2.75 之后,比例为2.75

try this it may help you. 试试这个可能对您有帮助。 because, I had faced same problem, so just added this and get resolved my problem. 因为,我曾经遇到过同样的问题,所以只需添加此问题即可解决我的问题。 enjoy! 请享用!

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 QLn220是一台2英寸打印机@ 200dpi,这意味着您可以得到的最大宽度约为400点。尝试在打印之前将打印图像线更改为这样的尺寸以缩放图像

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 它可能是失真的图像,但不应切断

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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