First page of PDF in WkWebView rendered in pixels

I am having trouble rendering a multi-page PDF file in WkWebView.

If this is one page, it looks fine. But the first page of any multi-page PDF file looks bad. I can’t understand why.

Example

I load the request as follows

wkWebView.load(URLRequest(url: request as! URL))

I keep wkWebView inside another view and avoid scrolling in scrolling (there is a reason for this, I know how scrollView works). Then I set the height of the wWebView and scroll it to the same height as the contentSize.

wkWebView.frame.size.height = wkWebView.scrollView.contentSize.height
wkWebView.frame.size.width = UIScreen.main.bounds.width
wkWebView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
wkWebView.scrollView.delegate = self
+4
source share
2 answers

, , , wkWebView scrollView, , . , .

:

self.scrollView.addSubview(wkWebView)
wkWebView.load(URLRequest(url: request as! URL))

:

wkWebView.load(URLRequest(url: request as! URL))
self.scrollView.addSubview(wkWebView)

: fooobar.com/questions/1269286/...

+5

:

[self.wkWebView loadFileURL:fileURL allowingReadAccessToURL:baseUrl];

: FileURL, HTML BaseUrl - HTML . , baseUrl fileURL !

-3

Source: https://habr.com/ru/post/1691776/


All Articles