我有一个 UIWebView,其中包含由 Google Charts 生成的图形(呈现的 JavaScript)
屏幕不是pdf或png。
是否可以捕获屏幕上的内容并将其发送到 AirPrint?
最佳答案
截取 web View 并将其发送到 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();
关于iphone - 打印 UIWebView 屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6313256/