I have the following code for printing, I want it to print the UIVIew of the view controller that the class is attached to,
but printing just generates empty white pages (and two pages instead of one)
I am fairly new to xcode, can you please help spot the mistake?
UIPrintInteractionController *pc = [UIPrintInteractionController
sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"Print file";
pc.printInfo = printInfo;
UIViewPrintFormatter *Pformatter = [self.view viewPrintFormatter];
pc.printFormatter = Pformatter;
UIPrintInteractionCompletionHandler completionHandler =
^(UIPrintInteractionController *printController, BOOL completed,
NSError *error) {
if(!completed && error){
NSLog(@"Print failed - domain: %@ error code %u", error.domain,
error.code);
}
};
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[pc presentFromBarButtonItem:self.btnPrint animated:YES
completionHandler:completionHandler];
} else {
[pc presentAnimated:YES completionHandler:completionHandler];
}