我使用以下代码创建了一个给定HTML字符串的webView:
let filePath = Bundle.main.path(forResource: "my file name", ofType: "html")
let htmlStr = try! NSString.init(contentsOfFile: filePath!, encoding: String.Encoding.utf8.rawValue)
webView.loadHTMLString(htmlStr as String, baseURL: nil)
webView
正确显示HTML,但当我尝试打印时,打印面板显示为空白页,我使用了这个:
webView.printView(nil)
我也尝试过这个:
NSPrintOperation(view: webView).run()
所有出现的打印面板都有空白页!有帮助吗?