Post

Replies

Boosts

Views

Activity

Reply to How to print WKWebView in Sequoia?
I had all sorts of problems with printing from WKWebView and wasted days with AI's. The winning combination for me was: static func print(_ webView: WKWebView, jobTitle: String = "Web Content") { let printInfo = NSPrintInfo.shared.copy() as! NSPrintInfo printInfo.jobDisposition = .spool printInfo.orientation = .portrait printInfo.topMargin = 36 printInfo.bottomMargin = 36 printInfo.leftMargin = 36 printInfo.rightMargin = 36 printInfo.isHorizontallyCentered = true printInfo.isVerticallyCentered = false printInfo.horizontalPagination = .fit printInfo.verticalPagination = .automatic printInfo.setUpPrintOperationDefaultValues() let op = webView.printOperation(with: printInfo) op.view?.frame = webView.bounds guard let window = webView.window else { return } op.showsPrintPanel = true op.showsProgressPanel = true op.jobTitle = jobTitle op.runModal(for: window, delegate: nil, didRun: nil, contextInfo: nil) }
Topic: Safari & Web SubTopic: General Tags:
2w