Printing a PDF with UIPrintInteractionController ios 5 works but in ios 6 doesnt work and crash my app
Asked Answered
S

1

6

I have a problem with UIPrintInteractionController I send a pdf to print and with a devices with ios 5 when i press print button is send the file to the printer and works. but when I test on a devices with ios 6 I doesn't work and crash the app.

when the view of the UIPrintInteractionController presented on ios 6 this 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 is a NMutableSData type)

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 dont have a AirPrint supported Printer but i used the handyPrint. Note: on iOS 6 it works printing with safari using handyPrint.

Anyone Knows what is wrong? =(

Swell answered 20/6, 2013 at 16:16 Comment(6)
Have you tried printing just one PDF doc or does this happen with any PDF doc you try to print?Scolecite
i have trying with a Pdf on the project bundle also a UIimages and in ios 5 it works and ios 6 crash.Swell
I am not aware of any changes to UIPrintInteractionController from iOS 5 to iOS 6. Perhaps the problem is not with UIPrintInteractionController but rather handyPrint running on iOS6. If possible try using AirPrint to at least rule out this possibility.Scolecite
handyPrint its a mac os x aplication. that use the shared printers and convert as a airprint. but the weried of this is that when i use Safari on the ios 6 devices and send a page to print it works.Swell
I hear you but your error log seems to suggest that "Get-Printer-Attributes failed:". This seems to suggest that handyPrint is not seeing/forwarding a printer to your app. Unless I am interpreting the error log wrong..?Scolecite
another test that i do is download a third app like my scans and print a document via airprint and it works. i think there will be somenthing wrong in the code. or that missing something to my app that supporting airprint on ios 6.Swell
M
1

Test it with the AirPrint Printer Simulator that comes with Xcode. The problem might very well be in handyPrint not supporting new features in AirPrint.

Monodic answered 22/8, 2013 at 5:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.