4
votes

I have an app opening URLs that may be PDFs. I can detect a PDF is opened in the UIWebView control, and if so, I propose to save it locally, in the iPad. To date, the only solution I found (as described in this topic : Save PDF which is displayed by UIWebView locally, is to RELOAD the remote PDF file in a new NSData object, then save it to disk.

Is it possible to use the UIWebView's NSData property, and write it directly on the disk, to avoid reloading a potentially large PDF file that is already loaded and displayed ? Thanks to all.

2

2 Answers

1
votes

I think you can't access the data that the UIWebView caches. But, you can download first the PDF and later display in UIWebView from the local PDF.

EDIT

Reading your question I understand that:

  • First you display the PDF in you UIWebView.
  • You ask the user for download.
  • You download the PDF (Second request for the PDF).

I propose you:

  • Check that the URL is a PDF.
  • Ask user to download.
  • Download it.
  • Display the PDF in UIWebView loading the local file.
0
votes

Did you examine the UIWebView content, using...

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

It could help you to understand how the WebView deals with the content of the PDF file