问题描述:

My iOS application has a WKWebView. An iframe within that WKWebView contains a dynamically-generated PDF (a blob). The PDF displays fine. I would like to access the PDF data to save it locally (so it can be cached, printed, emailed...).

I can access the frame itself like this:

let script = "document.getElementById(\"idOfTheFrame\").src"

self.webView.evaluateJavaScript(script) { (object:AnyObject?, error:NSError?) in

print("Script returns: \(object)")

}

Console displays:

Script returns: blob:https://domain.com/dynamically-generated-string

How can I copy the PDF to an NSData so I can save it to a file?

相关阅读:
Top