空气打印图像在页面中显示不必要的线条

Air printing image showing unnecessary lines in page

我正在尝试使用空气打印机打印图像。一切正常,除了打印页面包含不必要的行

这是我的打印代码

UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];
    if(!controller){
        NSLog(@"Couldn't get shared UIPrintInteractionController!");
        return;
    }

    controller.delegate = self;
    UIPrintInfo *printInfo = [UIPrintInfo printInfo];
    printInfo.outputType = UIPrintInfoOutputPhoto;
    printInfo.orientation = UIPrintInfoOrientationLandscape;
    printInfo.jobName = @"AirPrintSample";
    controller.printInfo = printInfo;


    UIImage *printImage = [self imageWithView:self.printView];
    controller.printingItem = printImage;

    void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {

        if(completed && error)
        {
            NSLog( @"Printing failed due to error in domain %@ with error code %lu. Localized description: %@, and failure reason: %@", error.domain, (long)error.code, error.localizedDescription, error.localizedFailureReason );
        }
        else
        {
            if(completed)
            {
               // Did Some Other[enter image description here][1] Stuff
            }
        }
    };

    if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        [controller presentFromRect:self.view.frame inView:self.view animated:YES completionHandler:completionHandler];
    }
    else {
        [controller presentAnimated:YES completionHandler:completionHandler];
    }

这是 UIView 到 UIImage 转换的代码

- (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;
}

这是打印后的样子 我们可以看到有很多水平线。但是我的标签需要一个简单的白色背景。而且我确定不会在图像上绘制这条线,打印预览也不会显示任何线条。如果有人可以提供帮助,请提前致谢。

打印机型号 - Brother ql-720nw

好吧,我自己找到了答案。我为转换为图像的 UIView 使用浅灰色背景色。当我将背景色设为白色时,效果非常好。我猜这种类型的打印机不能用其他颜色绘制完整的背景。如果有人用air printer搭配这种标签打印机(兄弟ql 720nw)最好用白底。