开发者

high resolution screenshot / or pdf from uiwebview

开发者 https://www.devze.com 2023-01-17 21:06 出处:网络
I want to save a screenshot or generate a pdf from UIWebView text content. I know about how to make screenshots like described in:

I want to save a screenshot or generate a pdf from UIWebView text content. I know about how to make screenshots like described in:

http://developer.apple.com/library/ios/#qa/qa2010/qa1703.html

The thing is I'd like to have the screenshot in 300dpi. It is a fixed requirement to generate the content in a UIWebView.

I thought about generating touches for zooming into the UIWebView, make severa开发者_Go百科l screenshots at a high zoom and stitch them together.

Does anyone have a more elegant solution?

Thanks b00tsy


The thing is I'd like to have the screenshot in 300dpi. It is a fixed requirement to generate the content in a UIWebView.

I'm not sure this can easily be done.

UIWebView uses WebKit. It appears to render to tiles in the background and seems to do some pre-rendering, but if you scroll quickly you can sometimes see tiles which weren't rendered soon enough. There's no easy way to know when WebKit has finished rendering the page.

The least ugly way might be to generate a larger-than-fullscreen UIWebView and render its layer. Setting scalesPageToFit = YES might help.

Also note that UIWebView takes the screen resolution into account while rendering (i.e. it does high-res rendering on iPhone 4). This means that you'll get better results on iPhone 4/iPod Touch 4g. This also means that you might be able to "trick" UIWebView into thinking that the screen is higher-res than it really is (you might have success with setting webView.layer.contentsScale on OS 4.0+).

(And FWIW, "300 dpi" is a vague requirement — the "retina display" exceeds 300 ppi.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号