PDF reading on Android - android

I have to make an application that should capable of reading PDF documents on Android device. Actually I do not want my app to be dependent on other apps to read the PDF file.
I had gone through the questions that are asked here and at some other places also. They all directly or indirectly using third party app.
Is there any API or something similar is available through which I can implement reading of PDF files directly in my app? How about converting the PDF document to PNG image? But the PDF-PNG method wont let users select the texts.
Any suggestions?
Thanks

There exists an library from Adobe that you can use. Its based on the NDK and you need to do the wrapping all by yourself. Its also extremely expensive, basically nothing for a small firm/single developer but for bigger companies. Afaik the license is not only expensive but also annual based, so you need to pay for it in every year...
There are other libraries, basically open source. Some of them have good performance but a lack of functionality (most of them based on NDK, too). I found only one pure "java" library but the performance was more than worse (loading time 10sec for a page and more).
There are three possibilities you should consider:
Using an external application, so you just need to implement the library of your PDF documents
You write everything by yourself including a pdf reader part
You create a middle "tier" where you convert your PDF into PNGs or JPG (I prefer PNG for better quality). The much better performance comes with a lack of features.
I'm currently developing a complex application like mentioned in 3. but I can't go into details, sorry.

I would definitely recommend the Qoppa stuff on Android.

Related

What is the best strategy for creating, displaying and printing pdf documents in android

I plan to use the built-in android pdf library. In my app I need to display a pdf report that may consist of several pages. Users should be able to print those pages. Printing with the PrintDocumentAdapter seems pretty straight forward, but what's unclear to me is what is the best way to create the pdf. I know that you can generate a PdfDocument with simply a View/canvas and or take more "low-level" approach where you draw lines,text, paint, etc.
I see three possibilities:
Create a view for each page. The user can navigate between the views as needed and print. However it's unclear to me how to generate a pdf for each page/view. What I mean by this is if I'm viewing page/view 1, yes I can easily create a pdf from this, but what about the other pages? Yes I can have this in memory, but what I've found is if they aren't actively being displayed on screen, they create empty pdfs. I don't want to have the user print each page individually.
Create the pdf documents (low-level approach), integrate a pdf reader and just display/print the pdf from there.
Create a view for each page that the user can navigate through. When the print option is invoked, generate the pdf documents again (low-level approach)
Obviously option 1 is the preferred approach, but I'm not clear on how I can do that. Of course, I could be missing something here so any help would be appreciated!
Android didn't have built in pdf genaration library, but in API19 android provided an api https://developer.android.com/reference/android/graphics/pdf/PdfDocument.html
But as #Ivan Wooll said itext is a nice pdf generation library if you want to use.
...but what's unclear to me is what is the best way to create the pdf...
Yet, it is relative. It really is a matter of what library/framework you find more convenient to work with, because each of them offers quit the same functionality with its own disadvantages. For instance, those I worked with, have the following ones:
iText - you must buy a licenece for comircial use (see What is latest version of itext that is not AGPL?);
Android Print Framework - no built-in pdf preview before printing as you mentioned in the 2nd item (you can use built-in PdfRenderer though for API 21+; also see Display PDF within app on Android?). Another disadvantage is the disturbing system dialogs when you'd like to save/print "silently" :)
Even the official documentation states that "You can use any PDF generation library to generate a PDF document and pass it to the Android print framework for printing."
...Yes I can have this in memory, but what I've found is if they aren't actively being displayed on screen, they create empty pdfs...
The reason for empty pdfs when you keep the views that have been left by a user in memory is their 0-dimension because of not being laied out (see Android: PdfDocument generates empty pdf). The same will happen if you try to inflate the views that haven't been reached by a user yet... In fact, there is nothing you can do about it, this is how Android works.
I don't want to have the user print each page individually.
In this case I suggest you to create pdf pages in advance for each content view a user is currently interacting with, just make sure that the view is still laied out when drawing it on canvas. For the views that aren't currently laied out use the "low-level approach". And once printing requested pass the output pdf to Android Print Framework.
There are a few pdf generation libraries out there. Itext being the simplest to use but it's ludicrously expensive. Pdfjet is another one which is reasonably priced. A quick google will provide you with more i'm sure.

ebook formats and mobiles

I have an app for android and iOS. I want to add in app option, which allow user select book from list and read it.
List of available books will be load from server.
Now i wondering which book format to choose. First i'm thinking about pdf, but it has not-flexible reflowing for different screens(books contains sheets and formules). Maybe .epub would be good choice?
ps. is this possible to prevent user copy loaded book files?
Should i load files only in memory(without saving on sd), but how then work with files exceeded ram memory?
have you know any good iOS and android libraries, sdk for reading ebook files?
I am searching for the same SDK options and found this for ePub:
http://skyepub.net/downloads/
There are handfuls of PDF SDKs. Throw a dart at the internet and see what it hits, however, I would like to know which ones have risen to the top (e.g., the top 3).
Still looking for .mobi (Kindle's format).

Runtime resource files with PlayN

Working on a game that would like to allow users to select different character skins using PlayN (targeting Android as first platform). But these character skins will be made available later on (and due to their size, player may not want to download ALL skins). So rather than create a large bundle with all skins, is there a way for PlayN to access different resource files at runtime? We can setup a server backend for players to browse the latest available skins.
Any help/pointer is greatly appreciated.
You can use Assets.getRemoteImage to load images remotely.
There is currently no way to cache the downloaded images, which makes this non-optimal for your purposes, but I'm going to add support for caching the downloaded images which should make it work reasonably well if you use texture atlases and don't have a ton of images to download.
If you do need to download dozens or hundreds of images in one fell swoop, then you'll need to write custom per-backend code to handle that (and you'll have to give up using the HTML backend, because it cannot do things like download a zip file and unpack it into local storage).

Flash Builder, loading assets for mobile devices

I am using flash builder to make an app for android/ios.
How would you recommend I use assets such as images and sounds. Should I embed them or use loader?
Any benefits to each one.
I have a fair amount of assets.
I am no expert on flash, but I ended up embedding the resources. The ease of compile-time resource checking. You just need to be sure to load each images/sounds when you have enough time to do so between frames.
For mobile apps embed is just easier. You don't need to worry about accessing the file system and purchasing/downloading is easier since you are not bundeling anything with it. The initial download will be about the same size unless you were planning on loading the assets to the device at runtime from the web. I would caution against that unless it was absolutely necessary. My experience is user are accustomed to a large download, but but load time of the app each time it opens should be minimal.
I also like that FlashBuilder will check your embed code and make sure the file is present and spelled correctly - one less thing to worry about

Produce thumbnail from pdf on Android

I am managing a bunch of PDF files in an android application maintaining a list of records in a SQLite database as well as storing the pdf files on the external storage.
Now I would like to present a thumbnail of the first page of the pdf in my list view as part of each cell representing a pdf.
I am aware of libraries like iText, fop.. on the JavaSE side that can render a PDF but I would rather not delve into embedding a large library like that. On a similar approach I would also rather not embed a native PDF viewer like droidreader, apv or vudroid.
Otherwise I could of course also get it rendered on a server via some webservice but that is a lot of headache as well.
I am already using intents to get the pdf's displayed for the user so I was thinking it would be great if I could get a thumbnail via a intent call as a result somehow. However I found nothing on the web (e.g. on openintents) that indicates something like that exists ..
So I am a bit at a loss on what to do? What do you think is the best approach to get these thumbnails into my app? Are there any public intents available? Or did I just totally miss something and the SDK provides features for that already (it should imho but currently does not)?
You are going to get a lot faster resopnse rasterizing the PDFs on the server and there are lots of libraries to do this in C, Java, Php.

Categories

Resources