I'd like to allow a user to print a folder of PDFs (pdfList array). I can't seem to get the code below to work. I keep getting the errow message below. I'm new to coding, and trying to modify some existing code. I get the sense of the error. I need to provide more information about the PDF, but don't know what to do. Suggestions?
Error:
ERROR: attempting to display print options with no printing source (item/items/formatter/renderer) set
- (IBAction)printAllPDFs:(id)sender {
Class printControllerClass = NSClassFromString(@"UIPrintInteractionController");
if (printControllerClass) {
printController = [printControllerClass sharedPrintController];}
NSFileManager *fileManager = [[NSFileManager alloc] init];
for(int i = 0; i < _pdfList.count; i++){
printController.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [_pdfList[i] lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
printController.printingItem = [fileManager contentsOfDirectoryAtPath:_pdfList[i] error:nil];
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];
}
}