1

我想允许用户打印一个 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];
    }
}
4

0 回答 0