figured it out atlast ! had to change they way the AirPrint works. so it takes a screenshot of uiview and then prints that
- (void)printWebView:(id)sender {
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect rect=self.view.frame;
CGImageRef cropped1 = CGImageCreateWithImageInRect(viewImage.CGImage, rect);
UIImage *imges = [UIImage imageWithCGImage:cropped1];
CGImageRelease(cropped1);
// squarecropimg.image=imges;
NSData *date=UIImagePNGRepresentation(imges);
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *doc = [paths objectAtIndex:0];
NSString *appstr = [doc stringByAppendingPathComponent:@"currentview.png"];
[date writeToFile:appstr atomically:YES];
UIPrintInteractionController *printer = [UIPrintInteractionController sharedPrintController];
printer.printingItem = viewImage;
UIPrintInfo *info = [UIPrintInfo printInfo];
info.orientation = UIPrintInfoOrientationLandscape;
info.outputType = UIPrintInfoOutputGeneral;
printer.printInfo = info;
UIPrintInteractionCompletionHandler completionHandler =
^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
if (!completed && error)
NSLog(@"FAILED! due to error in domain %@ with error code %ld: %@",
error.domain, (long)error.code, [error localizedDescription]);
};
if (IDIOM == IPAD)
[printer presentFromBarButtonItem:sender animated:YES completionHandler:completionHandler];
else
[printer presentAnimated:YES completionHandler:completionHandler];
}