You need to stitch the images together. You can get the Webview contentSize using javascript:
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (height, error) in
self?.webViewContentHeight = (height as? CGFloat) ?? -1
})
You can use a UIGraphicsImageRenderer to to create an image context of that size then render each page of the web view in the image context:
let image = UIGraphicsImageRenderer(size: CGSize(width: webview.bounds.size.width, height: webViewContentHeight)).image { [webview] context in
for offset in stride(from: 0, to: Int(webViewContentHeight), by: Int(webview.bounds.size.height)) {
let drawPoint = CGPoint(x: 0, y: CGFloat(offset))
webview.scrollView.contentOffset = drawPoint
webview.drawHierarchy(in: CGRect.init(origin: drawPoint, size: webview.bounds.size), afterScreenUpdates: true)
}
}