2016-06-05 2 views
0

Im пытается распечатать изображение с помощью воздушного принтера. Все работает отлично, за исключением после того, как она напечатана страница содержит ненужную линиюИзображение с воздушной печатью, показывающее ненужные строки на странице

Вот мой код для печати

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

+0

Вот ссылка для печатной страницы [ссылка] (http://i.stack.imgur.com/WKyoW.jpg) –

ответ

0

Окей я нашел ответ сам. Я использовал светло-серый цвет backgroud для UIView, который я преобразовал в изображение. Когда я сделал цвет фона белым, он отлично работает. Я предполагаю, что этот тип принтера не может нарисовать полный фон с другими цветами. Если кто-либо использует принтер с принтером этикеток (брат ql 720nw), лучше использовать белый фон.

 Смежные вопросы

  • Нет связанных вопросов^_^