Three defensive fixes for WKWebView.createPDF() rendering text far
larger than the source HTML's actual font sizes specify:
- Added a viewport meta tag and explicit -webkit-text-size-adjust:
100% — WebKit's shared engine has a text-autosizing heuristic
(normally associated with mobile Safari, but can trigger in WKWebView
contexts too, especially for content loaded via loadHTMLString with
no base URL) that boosts font sizes for perceived readability; this
disables it explicitly rather than relying on it not firing.
- Explicit body font-size (was previously unset, relying on WebKit's
default) and webView.pageZoom = 1.0.
- Resize the webview to the actual rendered content height
(via document.body.scrollHeight) before calling createPDF, instead
of relying on its undocumented auto-sizing against the arbitrary
initial frame — a bounds mismatch here is a known cause of
blown-up/rescaled PDF output.