I am using wkWebView
to access research papers from IEEE, Science Direct, and other sources. When I click on a PDF in the research papers, it gets loaded into the webview. Is there a way to detect and enable a download icon in wkWebView
?
Attempted Solution:
I have used URLSession
to retrieve PDFs from URLs, which works 95% of the time. However, sometimes the content is not fetched via URLSession
due to dynamic URL/PDF creation, resulting in the PDF being loaded into the webview.
During my research, I found: Get already loaded PDF directly from WKWebView without downloading again. In my case, I first need to verify if the content loaded is a PDF.
A related query: add download button for pdf in wkwebview in swift 4, but unfortunately, there was no answer.
To test: open this URL: in wkWebView
and click on the "Download PDF" button to load the PDF into the webview.
In essence: Is there a way to identify if the loaded content is a PDF and provide a download button to save the PDF content to the documents folder?
Any assistance would be greatly appreciated. Thank you.