iphone - iOS 4.2 - 使用 Apple AirPrint 打印 DOC、PPT、XLS 等?

标签 iphone ios uiwebview airprint

我一直在玩 iOS 4.2 UIWebView + AirPrint。然而,问题是,从 UIWebView 获取 viewPrintFormatter 我能够打印 PDF 和图像,但不能打印 DOC、DOCX、PPT、PPTX 等。这些文件在 UIWebView 中正确显示,但 Airprint 将打印空白页.

这是我的代码:

  [internalWebView loadData:[[printContent objectAtIndex:0] data] MIMEType:mimeType textEncodingName:nil baseURL:nil];

UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
//pic.delegate = self;

UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [[printContent objectAtIndex:0] fileName];
pic.printInfo = printInfo;

pic.printFormatter = [internalWebView viewPrintFormatter];
pic.showsPageRange = YES;

void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
 if (!completed && error) {
  NSLog(@"Printing could not complete because of error: %@", error);
 }
};

[pic presentAnimated:YES completionHandler:completionHandler];

最佳答案

我找到了如何修复它,出于某种原因,如果我不使用它可以工作的 mime 类型。我只是将文件保存到本地存储,并使用 webview 的其他加载方法,仅根据 URL 加载内容。希望对您有帮助...

关于iphone - iOS 4.2 - 使用 Apple AirPrint 打印 DOC、PPT、XLS 等?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4463223/

相关文章:

iphone - GMSGroundOverlay 有哪些限制?

iphone - 如何在 UIImageView 上制作可点击的 UIButton?

ios - Cordova截图插件: doesn't work on iOS

iphone - UILabel 未以编程方式更新

iphone - 在 Objective-c 中实现协议(protocol)方法

iphone - iOS 应用程序分区/MVC

ios - 解开可选值错误 - 检查应用内购买的收据响应

iphone - Objective C - UIWebview 只加载网页的特定部分?

javascript - 如何在 UIWebview 中启用 JavaScript

iphone - 来自不同类的 loadRequest UIWebView