How to save a PDF file displayed in a UIWebview control (WITHOUT rebooting it from the network)?

I have application open URLs that can be PDF files. I can find that the PDF is open in the UIWebView control, and if so, I suggest saving it locally on the iPad. To date, the only solution I have found (as described in this section: Save a PDF that is displayed locally by UIWebView is to RESTART the deleted PDF file in a new NSData object, then save it to disk.

Can I use the UIWebView NSData property and write it directly to disk to avoid reloading the potentially large PDF file that is already loaded and displayed? Thanks to everyone.

+4
source share
2 answers

I think you cannot access data that caches a UIWebView. But you can download the PDF first and then display it in the UIWebView from the local PDF.

EDIT

Reading my question, I understand that:

  • First, you show the PDF in UIWebView.
  • You are asking the user to download.
  • You are downloading a PDF (Second request for PDF).

I suggest you:

  • Make sure the URL is a PDF file.
  • Ask the user to download.
  • Download it.
  • Display the PDF in UIWebView by loading the local file.
+1
source

You examined the contents of UIWebView using ...

NSString HtmlCOntent = [NSMutableString stringWithString:[self.webView stringByEvaluatingJavaScriptFromString:@"document.body.outerHTML"]]; 

This can help you understand how WebView deals with the contents of a PDF file.

0
source

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


All Articles