Is it possible to print from iPhone & iPad app?
Asked Answered
G

2

7

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?

Gaye answered 7/2, 2011 at 7:0 Comment(0)
M
18

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];

    } 
Melissiamelita answered 17/2, 2012 at 10:56 Comment(0)
V
6

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

Villager answered 7/2, 2011 at 7:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.