WKWebViewControlMBS Zoom In & Out (Mac)

I am using a built-in HTML Viewer and was able to implement the ZoomPageInMBS and ZoomPageOutMBS. However, seeing that Apple is recommending that we moved to WKWebView, I suddenly find that there isn’t the option to perform the above. It does not seems to have the pinch to zoom gesture support like in Safari.

Is there a way to implement the ZoomPageIn and Out ?

Thanks.

I’ll add magnification properties.

Does WKWebview now allow printing?

Sorry, no.
And in FileMaker they use a WKWebview and if you do printing, they create an old WebView, load website there and print it.

Filemaker is pretty perverted anyways. I only need the WKWebview for printing - unfortunately.

Thank you Christian. Just gave it a spin and it works great.

[quote=453840:@Christian Schmitz]Sorry, no.
And in FileMaker they use a WKWebview and if you do printing, they create an old WebView, load website there and print it.[/quote]
Isnt a WKWebView a subclass of NSView which does permit printing ?

I tried the mWKWebViewControlMBS.NSViewMBS.print and it did evoke the Print Dialog but the Preview window is blank.

Just because NSView offers a generic print method, it’s up to the controls whether they implement it.
And WKWebView doesn’t do printing.

Stupid question: what does Safari use?

Safari is special. It may have it’s own private extensions to WKWebView.

That is totally clever.

That’s very much what Apple would do. Locked us into using something new but does not provide all the full features in the name of “security”.

Have not tried but it might be possible to do a snapshot and print that instead.

I’m not only printing but also saving the PDFs. With a snapshot the PDFs would be much larger.

Perhaps they’re using this private extension: https://github.com/WebKit/webkit/commit/0dfc67a174b79a8a401cf6f60c02150ba27334e5

[quote]Looking at https://github.com/WebKit/webkit/commit/0dfc67a174b79a8a401cf6f60c02150ba27334e5 , printing was implemented years ago as a private API, but for some reason, has not been exposed. If you don’t mind using a private API, you can print by adding this to your view controller:

open override func printOperation(withSettings printSettings: [NSPrintInfo.AttributeKey : Any]) throws -> NSPrintOperation { let printSelector = (Selector("_printOperationWithPrintInfo:")) // https://github.com/WebKit/webkit/commit/0dfc67a174b79a8a401cf6f60c02150ba27334e5 if webView.responds(to: printSelector), let printOperation: NSPrintOperation = webView.perform(printSelector, with: self.printInfo)?.takeUnretainedValue() as? NSPrintOperation { return printOperation } }
[/quote]

I can try that. Thanks

Seems to work. Thanks @Walter Purvis for the tip. I’ll add it for my control.

Christian, were you successful? I wonder if using the hidden Print command would fix my problems with screen capture? See https://forum.xojo.com/56168-catalina-screen-recording-permissions/0#p456451 Do you know if Print will capture video and WebGL content?

Hmm, doubtful this would work - testing WebGL demos in Safari, I see that print to PDF never captures the WebGL content at all, so doubtful this would work in Xojo / MBS. Nevermind.

Well, I just added printOperation method to WKWebViewControlMBS control so you can now print.
No idea what it may help with otherwise!?