Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to print from iPhone & iPad app?

From my application, how can I allow a user to print a document or page from an iPhone or iPad? Which versions of iOS support printing?

like image 853
sri Avatar asked Feb 07 '11 07:02

sri


People also ask

Can any printer connect to iPhone?

Related. Apple's iPhone smartphone lets you print wirelessly using any Wi-Fi enabled printer on your wireless network. Printers are added to the device through the "Printer Options" menu. Unlike most of the device's settings menus, the "Printer Options" menu cannot be accessed through the "Settings" application.

Can I use a normal printer from an iPhone?

Even if your printer isn't AirPrint enabled you may still be able to print from iPhone and iPad. The most common way this works is through an app from the manufacturer. For example, you can browse your iPhone or iPad's documents, photos, and more directly from the app and quickly print.


2 Answers

Here is a Simple Code .

-(void)printItem {

    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [self.view.layer renderInContext:context];
    UIImage *imageFromCurrentView = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
    printController.printingItem = imageFromCurrentView;
    UIPrintInfo *printInfo = [UIPrintInfo printInfo];
    printInfo.outputType = UIPrintInfoOutputGrayscale;
    printController.printInfo = printInfo;
    printController.showsPageRange = YES;


        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 presentAnimated:YES completionHandler:completionHandler];

    } 
like image 140
BigAppleBump Avatar answered Nov 09 '22 07:11

BigAppleBump


You can print on any multitasking capable devce which is running iOS 4.2 or higher. See this for more information: http://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/Printing/Printing.html#//apple_ref/doc/uid/TP40010156-CH12-SW1

like image 32
Moshe Avatar answered Nov 09 '22 07:11

Moshe