3

I was wondering if there's a way to print from ios app without using UIPrintInteractionController ? As it supports only air print compatible printers.

I have succesfully implemented Air print printing though using:

    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");
    }    
rckoenes
  • 69,092
  • 8
  • 134
  • 166
nr5
  • 4,228
  • 8
  • 42
  • 82

0 Answers0