Function that sends an image to AirPrint

Im trying to find a function that lets me print using AirPrint.

I have a button btnPrint, that when pressed, should print myPic.jpg to the default AirPrint device. But I cannot figure out if there even is such a function.

I cannot find a lot of documentation on AirPrint in xcode.


Apple has documentation on printing that would probably benefit you.

And the following is from Objective-C code for AirPrint:

Check wether printing is available:

if ([UIPrintInteractionController isPrintingAvailable])
    // Available
} else {
    // Not Available

Print after button click:

-(IBAction) buttonClicked: (id) sender;
    NSMutableString *printBody = [NSMutableString stringWithFormat:@"%@, %@",self.encoded.text, self.decoded.text];
    [printBody appendFormat:@"\n\n\n\nPrinted From *myapp*"];

     UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
     pic.delegate = self;

     UIPrintInfo *printInfo = [UIPrintInfo printInfo];
     printInfo.outputType = UIPrintInfoOutputGeneral;
     printInfo.jobName = self.titleLabel.text;
     pic.printInfo = printInfo;

     UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:printBody];
     textFormatter.startPage = 0;
     textFormatter.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins
     textFormatter.maximumContentWidth = 6 * 72.0;
     pic.printFormatter = textFormatter;
     [textFormatter release];
     pic.showsPageRange = YES;

     void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
     ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
         if (!completed && error) {
             NSLog(@"Printing could not complete because of error: %@", error);

    [pic presentFromBarButtonItem:self.rightButton animated:YES completionHandler:completionHandler];


Need Your Help

test for html5 data equality among a set of elements without a loop

javascript jquery

When given a set of jQuery objects which all have the same data element, asking for the value of that data by with regards to class gives me only the first element.

Trouble With Overload Resolution

c++ operator-overloading overload-resolution

Id like to say that there's a ton of C++ Overloading questions already on SO, but after an hour of looking at them and other posts on forums and newsgroups, I'm still stumped.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.