Printing PDF using UIPrintInteractionController ios 5 works, but in ios 6 it doesn’t work and does not break my application

I have a problem with UIPrintInteractionController. I send pdf for printing and with devices with ios 5, when I press the print button, it sends the file to the printer and it works. but when I test devices with ios 6, I am not working and not crashing the application.

when the UIPrintInteractionController view presented on ios 6 is the log:

Save\032in\032folder\032Aptana\032Rubles._ipp._tcp.local.: Get-Printer-Attributes failed: Undefined error: 0 No document-format-supported attribute found or no supported formats found. No media-col-database found in response from printer. Defaulting to generic media size values. No print-quality-supported attribute found. Defaulting to normal quality. No sides-supported attribute found. Defaulting to single-sided. 

Here is my code: (self.myPDF - type NMutableSData)

 UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController]; if (controller && [UIPrintInteractionController canPrintData: self.myPDF] ) { UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputGeneral; printInfo.jobName = [NSString stringWithFormat:@"Coupon"]; printInfo.orientation = UIPrintInfoOrientationPortrait; printInfo.duplex = UIPrintInfoDuplexLongEdge; controller.printInfo = printInfo; controller.showsPageRange =NO; controller.printingItem = self.myPDF; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { if (!completed && error) { UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error." message:[NSString stringWithFormat:NSLocalizedString(@"An error occured while printing: %@", @"Printing error"), error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [av show]; [av release]; } }; [controller presentAnimated:YES completionHandler:completionHandler]; } 

I do not have an AirPrint-enabled printer, but I used handyPrint. Note: on iOS 6 it works with safari using handyPrint.

Does anyone know what is wrong? = (

+6
source share
1 answer

Test it with AirPrint Printer Simulator that comes with Xcode. The problem can be very convenient to use. The printer does not support the new AirPrint features.

+1
source

Source: https://habr.com/ru/post/947757/


All Articles