iPhone/iPad AirPrinting Tutorial

As of iOS 4.2, applications can print content wirelessly. When assembling a print job, they have three ways to give UIKit the content to print:

  • They can give the framework one or more objects that are directly printable; such objects require minimal application involvement. These are NSData,NSURL, UIImage, or ALAsset objects containing or referencing image data or PDF content.
  • They can assign a print formatter to the print job. A print formatter is an object that can lay out content of a certain type (such as plain text or HTML) over multiple pages.
  • They can assign a page renderer to the print job. A page renderer is usually an instance of a custom subclass of UIPrintPageRenderer that draws the content to be printed in part or in full. A page renderer can use one or more print formatters to help it draw and format its printable content.

Just go with below code.I also have attached sample code with it so please refer that code for more information.

This is .h file.

#import <UIKit/UIKit.h>

@interface AirPrintingViewController : UIViewController <UIPrintInteractionControllerDelegate>{




This is .m file

#import "AirPrintingViewController.h"

@implementation AirPrintingViewController

-(void)printItem {

NSString *path = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"png"];
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 presentAnimated:YES completionHandler:completionHandler];


- (void)viewDidLoad {
[super viewDidLoad];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn addTarget:self action:@selector(printItem) forControlEvents:UIControlEventTouchDown];
[btn setTitle:@"PRINT" forState:UIControlStateNormal];
btn.frame = CGRectMake(0, 100, 320, 50);
[self.view addSubview:btn];


Grab the code from Here

for more detailed document please click Here