无法打印PDF文件的文件夹

时间:2013-06-10 23:12:31

标签: ios uiprintinfo

我想允许用户打印PDF文件夹(pdfList数组)。我似乎无法让下面的代码工作。我一直收到下面的错误信息。我是编码的新手,并试图修改一些现有的代码。我明白了错误。我需要提供有关PDF的更多信息,但不知道该怎么做。建议?

错误:

  

错误:尝试显示没有打印源(项目/项目/格式化程序/渲染器)的打印选项

- (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];
    }
}

0 个答案:

没有答案