Android "L" Feature Spotlight: Android Finally Gets Native PDF Rendering Via The New PdfRenderer API
Ever wondered why you have to open up a PDF in Android on Chrome or using a 3rd-party viewer? Well, it's because up until now Android hasn't had a native PDF rendering tool in place. As of Android "L," it does. If you're on Android 4.4 or below, try opening a PDF in the Drive app - you'll be sent to whatever your native PDF viewing tool happens to be. Now, if you're on the "L" preview release, do the same thing in Drive (make sure no PDF viewers are installed, that might break this behavior), and you'll see the PDF displays natively in the app. Edit: Turns out this is QuickOffice, not a native viewer. However, the new renderer is still there and should still do what I described, it's just not implemented yet.
In terms of sheer convenience, this is pretty big. No one likes having to use a 3rd-party PDF viewer just to look at a file, and this almost definitely means you can expect native PDF viewing is on the way for any Google app that might require it. Gmail, for example. Here's the blurb from the Android "L" developer documentation on this new API class.
New api class: PdfRenderer
This class enables rendering a PDF document. This class is not thread safe.
If you want to render a PDF, you create a renderer and for every page you want to render, you open the page, render it, and close the page. After you are done with rendering, you close the renderer. After the renderer is closed it should not be used anymore. Note that the pages are rendered one by one, i.e. you can have only a single page opened at any given time.
Neat stuff.
source: androidpolice
0 comments :