iOS 4.2 — печать DOC, PPT, XLS и т. д. с помощью Apple AirPrint?

Я играл с iOS 4.2 UIWebView + AirPrint. Однако проблема заключается в том, что при получении viewPrintFormatter из UIWebView я могу печатать 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];

person cusquinho    schedule 16.12.2010    source источник
comment
есть какие-либо решения для того же самого. Даже я пытаюсь распечатать файл doc & ppt   -  person siva    schedule 10.06.2011


Ответы (2)


Я нашел, как это исправить, по какой-то причине, если я не использую тип пантомимы, он работает. Я просто сохранил файл в локальном хранилище и использовал другой метод загрузки для веб-просмотра, который загружает контент только на основе URL-адреса. Надеюсь, поможет...

person cusquinho    schedule 04.02.2011

Спасибо, я следую вашему совету, и теперь это работает. Вместо этого используйте loadRequest:

[internalWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
person Tùng Đỗ    schedule 26.09.2011