1

After I loaded ppt on UIWebView, in

func webViewDidFinishLoad(webView: UIWebView) {
    let html = webView.stringByEvaluatingJavaScriptFromString("document.documentElement.outerHTML")
}

I got the whole HTML for the ppt file.

But after I loaded .key or .pdf, the HTML is empty! So how are them loaded on UIWebView. Anyway I could get or set the content after I loaded them like ppt?

Jay Hu
  • 6,041
  • 3
  • 22
  • 33

1 Answers1

0

When you load a PDF document using UIWebView, you see in essence an image of the pages laid out in a scroll view. There is no HTML involved.

You ask about the "content" of the documents, but that does not really have a meaning in PDF. Think of a PDF documents as a set of instructions for drawing shapes, images and glyphs onto the screen.

As far as PDF is concerned, there is no such thing as a word, a paragraph, a heading and so on. And therefore, there isn't really such a thing as "content" in the same way as there is in an HTML page.

There are some libraries that try to recover structure from PDF, and the UIWebView uses one under the hood, at least to discover lines, words, paragraphs and columns, buy it is not accessible from the API, and therefore you cannot use it.

  • for PDF, i am not so worried, since I could CoreGraphics to make pdf into images and display. But what about keynote? is it just like PDF? under the hood lib and no access? – Jay Hu Sep 04 '15 at 04:23
  • I think you can use zlib to uncompress/uncompact keynote, and then see the underlying xml and file structures, but things may have changed. –  Sep 04 '15 at 19:32