I wrote a little something that uses WKWebView. It seems that print: does not work though (macOS app).
I'm kind of regretting using WKWebView over the old school WebView...anyone have a workaround?
I wrote a little something that uses WKWebView. It seems that print: does not work though (macOS app).
I'm kind of regretting using WKWebView over the old school WebView...anyone have a workaround?
Did you find any? I am having the exact same problem. You should be able to print a web page.
I'm having this problem and I can not find anything in the documentation, any tips ?
This is soluction:
go to Capabilities -> AppSandbox -> check all Network options
>This is soluction:
>go to Capabilities -> AppSandbox -> check all Network options
I hope that Apple considers that a workaround and not intended behavior... Where do you see AppSandbox? In System preferences? Is that new in Mojave?
Just to add a bit more info. I wrote a little Markdown editor and used WKWebView to show a preview of the rendered markdown. Couldn't get print to work at all. As mentioned in the original post I was regretting using WK. Rather than rewriting it in the old school webview I just reloaded the page in an offscreen old school Webview if the user hit print. Wasn't thrilled about that workaround. I think I filed a bug on this. Can't remember.
Now that they are getting rid of WebView I hope they fix printing on WK before that.
If I have to show an NSAlert when the user hits print and say "Go to Capabailities -> App Sandbox -> check all network options to print" I swear to G odddddd....
@cadu vieira is referring to settings in Xcode. Go to the target settings in Xcode, go to the Capabilities tab, and turn on the appropriate options in the App Sandbox section.
Ah nice. Sounds like this will be fixed in 10.14. ✅
I'm also having this problem, but I'm not trying to load a web page, but instead a locally generated HTML document.
This does not seem to be fixed on 10.14, even with the `com.apple.security.print`, `com.apple.security.network.client`, and `com.apple.security.network.server` entitlements enabled. Still always get blank.
WKWebView is certainly a pain - you can't load load images/resources without jumping through hoops (at least in a sandboxed app).
Will still use a legacy webview for printing for now...
If you are implementing any sort of features beyond just displaying a web page, WKWebview is really frustating to use all around.
Based on related links the issues does not appear to be resolved:
At least not resolved for me on macOS 10.14.6 (18G95) with Xcode 10.3
Someone on the Apple WebKit team tweeted about WKWebKit and I specifically asked about printing: twitter.com/bradeeoh/status/1136358340605251584
Although I did get a response, it was rather cryptic: "We have this request locked down."
I don't know what that means.
Code Block var appleViewToPrint = Platform.CreateRenderer(viewToPrint).NativeView; var printOp = NSPrintOperation.FromView(appleViewToPrint, NSPrintInfo.SharedPrintInfo); printOp.JobTitle = "Elderly and Infirm Rota"; printOp.ShowsPrintPanel = true; printOp.RunOperation();