iphone - UIPrintInteractionController 返回 UIPrintUnknownImageFormatError

标签 iphone ios ipad pdf printing

我正在尝试像这样打印通过 NSURLConnection 下载的 pdf 文档

    UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
    NSData *PDFData = urlConnection.receivedData;
    if  (pic && [UIPrintInteractionController canPrintData:PDFData] ) {
        pic.printingItem = PDFData;
        ...
        [pic presentAnimated:YES completionHandler:completionHandler];
    }

尽管 pdf 很好并且可以由任何 pdf 查看器打开,但我在 completionHandler 中收到 UIPrintUnknownImageFormatError。它可能有什么问题?

最佳答案

这个技巧有帮助:

    [receivedData writeToFile:filePath atomically:YES];
    NSData *PDFData = [NSData dataWithContentsOfFile:filePath];

关于iphone - UIPrintInteractionController 返回 UIPrintUnknownImageFormatError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10958983/

相关文章:

iphone - iOS 5—— "self"中的 presentModalViewController nils parentViewController?

ios - 具有多种颜色的大型导航栏文本

iphone - webkit img 100% 宽度问题

ios - 在 iOS 7 中检测静音模式

iOS 8 和 UIScreen 尺寸问题

ios - 具有动态高度的 UIWebView 导致内存崩溃

css - 使用后台附件 :fixed in safari on the ipad

ios - AVAssetWriter 可以透明写入文件吗?

ios - 用于启动 Google map 的 Url 架构在 iOS 9 中抛出警告并且也无法正常工作

iphone - 如何从 View 中隐藏 iphone 中的标题栏(顶部栏)