Stack OverflowにUIWebViewでAirPrintする話が載っていた(airprint - iOS Air print for UIwebview - Stack Overflow)ので、同じようにWKWebViewで出来るかやってみた。
出来た。
WKWebViewでAirPrintした話
以下、WKWebViewのインスタンスはself.wkWebView。
UIPrintInfo *pi = [UIPrintInfo printInfo];
pi.outputType = UIPrintInfoOutputGeneral;
pi.jobName = self.wkWebView.title;
pi.orientation = UIPrintInfoOrientationPortrait;
pi.duplex = UIPrintInfoDuplexLongEdge;
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.printInfo = pi;
pic.showsPageRange = YES;
pic.printFormatter = self.wkWebView.viewPrintFormatter;
[pic presentAnimated:YES completionHandler:^(UIPrintInteractionController *pic2, BOOL completed, NSError *error) {
// indicate done or error
}];
MacをAirPrintサーバーにしてMacのプリンタでAirPrintする
AirPrint対応のプリンタがない開発環境では、
MacをAirPrint Serverにして、
Macに接続されたプリンタからAirPrintすることが出来る。
[Netputing » handyPrint v5]
(http://www.netputing.com/applications/handyprint-v5/)は、MacをAirPrintサーバーにしてくれるアプリ。
上手くいかない場合、設定>共有>プリンタ共有 を有効にする必要があるかも。
