iphone - 打印 UIWebView 屏幕

标签 iphone ios ipad uiwebview airprint

我有一个 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/

相关文章:

javascript - 如何绕过 iPhone 中的 Captive Portal 问题

ios - 如何在选项卡栏上方显示操作表?

ios - 特殊字符 JSON iOS SQLite

ios - 内存泄漏: AVplayerViewController

iphone - 是否有将应用程序提交到 App Store 的(也许是官方的) list 和指南?

iphone - 在 UIScrollView 中显示 UIView 的子区域

iPhone:自动发布 - 何时发布(澄清)?

iphone - 为什么要使用@properties?

iphone - viewDidAppear 没有被调用

html - CSS 变换 : translate not working on iPad