在没有Airprint打印机的IOS中打印

时间:2013-05-23 07:09:24

标签: ios ipad airprint

我想知道是否有办法在不使用UIPrintInteractionController的情况下从ios应用程序进行打印?因为它仅支持兼容空气打印的打印机。

我使用以下方法成功实现了Air打印:

    NSString *path = [selectedForms objectAtIndex:[sender tag]];

    NSData *dataFromPath = [NSData dataWithContentsOfFile:path];

    UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];

    if(printController && [UIPrintInteractionController canPrintData:dataFromPath]) {
        printController.delegate = self;

        UIPrintInfo *printInfo = [UIPrintInfo printInfo];
        printInfo.outputType = UIPrintInfoOutputGeneral;           
        printInfo.jobName = [path lastPathComponent];            
        printInfo.duplex = UIPrintInfoDuplexLongEdge;

        printController.printInfo = printInfo;            
        printController.showsPageRange = YES;
        printController.printingItem = dataFromPath;

        void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
            if (!completed && error) {
                NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
            }
        };

        [printController presentFromRect:sender.frame inView:sender.superview animated:YES completionHandler:completionHandler];
    } else {
        NSLog(@"Your device is not configured for printing");
    }    

0 个答案:

没有答案