打印UIWebView屏幕

Ian*_*ink 1 iphone uiwebview ipad ios airprint

我有一个UIWebView,其中包含由Google Charts生成的图形(javascript呈现)

屏幕不是pdf或png.

是否有可能捕获屏幕上的内容并将其发送到AirPrint?

Pen*_*One 5

截取webview的屏幕截图并将其发送至AirPrint.

// TAKE SCREENSHOT
CGRect myRect = [self.view bounds];
UIGraphicsBeginImageContext(myRect.size);   
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, myRect);
[self.view.layer renderInContext:ctx];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
NSData *imageData = UIImageJPEGRepresentation(viewImage, 1.0);
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)