首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AirPrint UIImage A4

AirPrint UIImage A4
EN

Stack Overflow用户
提问于 2014-12-11 20:04:40
回答 2查看 532关注 0票数 0

我的应用程序当前正在创建一个大小为2480 3508 (A4页面)的图像,如何在A4页面上将此图像发送到AirPrint?一旦创建了图像,它会将其保存到照片应用程序中,我还想将其发送到打印。有什么想法吗?谢谢

EN

回答 2

Stack Overflow用户

发布于 2015-06-19 18:51:30

您将需要使用UIPrintInteractionController,并将图像设置为printingItem。根据您选择的打印质量(照片模式或标准),默认纸张可能小于a4,但用户可以在打印对话框中选择a4。

代码语言:javascript
复制
`- (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];
}`
票数 2
EN

Stack Overflow用户

发布于 2017-07-12 17:58:27

SWIFT 3版本

代码语言:javascript
复制
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)")
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27422456

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档