我的应用程序当前正在创建一个大小为2480 3508 (A4页面)的图像,如何在A4页面上将此图像发送到AirPrint?一旦创建了图像,它会将其保存到照片应用程序中,我还想将其发送到打印。有什么想法吗?谢谢
发布于 2015-06-19 18:51:30
您将需要使用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];
}`发布于 2017-07-12 17:58:27
SWIFT 3版本
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)")
}
}https://stackoverflow.com/questions/27422456
复制相似问题