2014-12-11 4 views
0

내 응용 프로그램은 현재 2480 3508 (A4 페이지)의 크기로 이미지를 만듭니다.이 이미지를 A4 페이지의 AirPrint로 보내려면 어떻게해야합니까? 일단 이미지가 만들어지면 사진을 사진 응용 프로그램에 저장하고 인쇄용으로 보내고 싶습니다. 어떤 아이디어? 감사합니다.AirPrint UIImage A4

답변

1

UIPrintInteractionController를 사용하고 이미지를 printingItem으로 설정해야합니다. 선택하는 인쇄 품질 (사진 모드 또는 표준)에 따라 기본 용지는 a4보다 작을 수 있지만 인쇄 대화 상자에서 a4를 선택할 수 있습니다.

`- (void) printImage: (UIImage *) myImage { 
UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController]; 
    UIPrintInfo *printInfo = [UIPrintInfo printInfo]; 
    printInfo.outputType = UIPrintInfoOutputPhoto; 
    printInfo.jobName = @"Testprint"; 
    printInfo.duplex = UIPrintInfoDuplexNone; 
    controller.printingItem = myImage; 
    controller.showsPaperSelectionForLoadedPapers = YES; 

    void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = 
    ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) { 
    if (!completed && error) 
     NSLog(@"FAILED! due to error in domain %@ with error code %u", 
       error.domain, error.code); 
     NSLog(@"Completed: %s", (completed?"YES":"NO")); 
    }; 
    [controller presentAnimated:YES completionHandler:completionHandler]; 
}` 
0

SWIFT 3 VERSION

func printNow(_ image: UIImage){ 
    let controller = UIPrintInteractionController.shared 
     let printInfo = UIPrintInfo.printInfo() 
     printInfo.outputType = .photoGrayscale//.photo 
     printInfo.jobName = "Testprint"; 
     printInfo.duplex = .none 
     controller.printingItem = image 
     controller.showsPaperSelectionForLoadedPapers = false 

     controller.present(animated: true) { (controller, completed, error) in 
      if (!completed && (error != nil)) { 
       print("FAILED! due to error \(error.debugDescription)") 
      } 
      print("Completed: \(completed)") 
    } 
}