Reputation: 63
UIPrintInteractionController uses data to be printed.if I want to print image from imageview it gives me some warning.I want to use image from imageview not from resources.I want to know how to get data from image in ImageView
UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
NSData * datatobeprinted [NSData dataWithContentsOfFile:imageView.image];
if(printController && [UIPrintInteractionController canPrintData:imageView.image]) {
printController.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [path lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
[printController setPrintingItem:datatobeprinted];
}
Upvotes: 0
Views: 478
Reputation: 3408
I think you need NSData from image, then you can do as follows:
NSData *imageData = UIImageJPEGRepresentation(image, 0.7); // 0.7 is JPG quality
or
NSData *imageData = UIImagePNGRepresentation(image);
Depending if you want your data in PNG format or JPG format.
Upvotes: 1