Printing contents of WKWebView (OS X)

前端 未结 3 1453
后悔当初
后悔当初 2020-12-17 16:24

I am trying to print the contents of a WkWebView, but when the print panel appears the print preview is empty.

Here is the code:

- (voi         


        
3条回答
  •  無奈伤痛
    2020-12-17 16:58

    If your app can require macOS 10.13 or later, there is a new method on WKWebView: takeSnapshot(with:completionHandler:), which generates an NSImage representation of your web view.

    As far as I know this is the best option for rendering a WKWebView to image.

提交回复
热议问题