Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iOS 4.2-使用Apple AirPrint打印文档、PPT、XLS等?_Iphone_Ios_Uiwebview_Airprint - Fatal编程技术网

Iphone iOS 4.2-使用Apple AirPrint打印文档、PPT、XLS等?

Iphone iOS 4.2-使用Apple AirPrint打印文档、PPT、XLS等?,iphone,ios,uiwebview,airprint,Iphone,Ios,Uiwebview,Airprint,我一直在玩iOS4.2UIWebView+AirPrint。但问题是,从UIWebView获取viewPrintFormatter后,我可以打印PDF和图像,但不能打印文档、DOCX、PPT、PPTX等。这些文件在UIWebView中正确显示,但Airprint将打印空白页 这是我的密码: [internalWebView loadData:[[printContent objectAtIndex:0] data] MIMEType:mimeType textEncodingName:nil

我一直在玩iOS4.2UIWebView+AirPrint。但问题是,从UIWebView获取viewPrintFormatter后,我可以打印PDF和图像,但不能打印文档、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加载内容。希望它能帮上忙……

谢谢,我听了你的提示,现在就可以用了。改为使用loadRequest:

[internalWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];

有任何相同的解决方案。即使我试图打印文档和ppt文件