WKWebview is not showing proper font from remote URL - swift

I am loading a remote url in WKWebview where only content is text. Text is loading properly but there in site they used 'Nunito' font, which is not showing here in my side. When i open url in browser text are showing properly with font even in safari borowser.
Here is my Code
let urlStr = "http://islamintel.com/cms/about-us"
if let url = URL(string: urlStr) {
let request = URLRequest(url: url)
wkWebView.load(request)
}

You need to add custom font (i.e Nunito) in the app. Here is the reference link on how to load custom font in WKWebView.

Related

How to you display a webview url in a UISearchBar

I have made a search-browser app and I can't figure out how to display the webview's URL for the current website you are on.
I tried mySearchBar.text = myWebView.url and it doesn't work.
I found out how you can do it with print but that doesn't help me.
print("URL: \(String(describing: myWebView.url))")

IOS WkWebview local content set base URL

Currently when loading a local html file it gets a really long URL:
like such:
Users/marcrasmussen/Library/Developer/CoreSimulator/Devices/....../index.html"
This is fairly annoying when some of my JavaScript is checking the url for routing.
Is it possible to set a base url of the WkWebview? an example would be app.mr.dk
Here is how i set the file to load:
let url = Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "iosbuild")!
webView.loadFileURL(url, allowingReadAccessTo: directoryURL)
https://github.com/radianttap/HTML2PDFRenderer
Try this, You can display HTML and also generate pdf
WkWebview local site Access Origin
some answers here is code

Open new tab from WKWebView html content in safari app extension popover

I'm developing a browser extension that share code between chrome and safari, basically it's an html page that I load up in a WKWebView on safari app extension (and an iframe on chrome extension).
Everything works fine apart from links that won't open in the safari app extension popover if they have target="_blank" or are popups like facebook login.
Anyone know if it is possible to have safari open them up as if clicked on in an ordinary safari tab?
I've tried to see if the WKWebView sets a global safari object in my html content, but it seems not, so this Safari Extension Popover Links does not work (results in ReferenceError: Can't find variable: safari).
This is how I load the web view in my SafariExtensionViewController:
override func viewDidLoad() {
super.viewDidLoad()
...
self.view.addSubview(webView)
webView.navigationDelegate = self
...
webView.load("\(baseUrl)?url=\(currentUrl)")
}
and an extension to make the load part work:
extension WKWebView {
func load(_ urlString: String) {
if let url = URL(string: urlString) {
let request = URLRequest(url: url)
load(request)
}
}
}
Safari Technology Preview 77 (6March 2019) and likely 12.1.x of regular Safari.
Made the window.safari object available in frames opened to safari-extension:// resources
https://webkit.org/blog/8658/release-notes-for-safari-technology-preview-77/
So if you go by that method you should be OK.

Instagram embed not working on some mobile devices

It loads the placeholder "View this post on Instagram" instead embedded media. Standard Instagram embed code is used, and this happens both in Chrome and Firefox browsers on the same device. Interesting, it is happening on Android and iOS, but only on small number of devices I test.
Any idea?
I ran into the same issue using a WKWebView in iOS 12. The solution that worked for me was to use an iframe with the standard link with "/embed" as the last path element, rather than the embed code provided by Instagram. Example from a viewDidLoad():
let embed = "<iframe src=\"https://www.instagram.com/p/BwdGxDGAOcP/embed\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\"></iframe>"
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
let webview = WKWebView(frame: view.frame, configuration: config)
webview.uiDelegate = self
view = webview
webview.loadHTMLString(embed, baseURL: nil)

PDF file not shown in iPad webView

I have a Swift application that opens a PDF file in webView with the function webView.load(request).
It perfectly works at debug time with the simulator, but when launched in the real device (an iPad) the PDF file is not shown.
The app does not set any error.
Any help is welcome
This might be so obvious question: Is your iPad connected to internet?
Then maybe it's because your link isn't and "https://...." but just an "http://" and maybe the webview won't open it because of that
The PDF file is located in the default documents folder.
Any loading to the webView is working, but not the loading of a PDF file.
The strange is that the same code works in the simulator.
For Swift 3 use this
let url = URL(fileURLWithPath: filePath)
let urlRequest = URLRequest(url: url)
webView?.loadRequest(urlRequest)