I want write an application which shows an PDF with some other content on it, like Video and image.
Generically I want shows an pdf with some other View on it.
I am concern about PDF, I read some article which explaine how to show an PDF but I want show an PDF with some other stuff.
Do you recommend me some solution or a right way?
Thanks a lot.
If you can render a PDF into your own View (and not launch a 3rd party Activity), you can just wrap that view into a FrameLayout, and draw whatever you want on top of it.
Related
I have searched a lot of libraries but can't find any exact solution for this. Actually i am working on an app in which i have to fetch pages (or content) as bitmap from pdf but also have to add the highlight property on content of pdf. I tried iText library, its good in fetching text and images from pdf. But it fetch text and images separately, not as exactly same as it is in pdf itself. I saw an app "Moon+Reader App". This app also fetch pdfs from our device an open them as shown in screenshot. Its a bitmaop image of a pdf page with selectable text. Is there any library which can do this, or if any other methodology is used then please help me by answer.
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.
I would like to ask advise if displaying pdf inside gridview instead of image is possible. I have tried to display list of websites in gridview using webview. Now, I want to make it a list of pdf files inside gridview. Normally same with if you open your folder in your linux laptop and have the thumbnails of your pdf, things like that. I want to achieve that in my application. I would really appreciate any of your advice, no codes needed cause i will handle it my self. I just want to have some theories. thanks and HAPPY NEW YEAR GUYS
I think what you're going to have to is convert the pdf's into a bitmap first, then load into an ImageView, check out this post and also look into other pdf rendering libraries for Android.
I have a ebook single HTML page having text, video and audios, which I want to display as book pages able to slide left & right to view the previous page and next page respectively.
How do I slice the data to show for a particular page for both
orientations ?
I am trying to use WebView for it. Any other possible options?
Is HTML is a best way to store the content? Other options?
Well if you want to make an ebook reader you have to consider that the user may not be connected always to internet, so a web view implementation might cause frustration.
My advice is to go for a native version that download the text/images and act like a real text book reader. Maybe with android animation you can create effects and a nice look :)
Good luck,
Arkde
I need to have a custom pdf viewer inside my application where i have my own menu and all.
It is not working with webview and i tried by converting each page into image but i feel its not a good way and it make my application big and complex.
Is there any way to create custom pdf view in
suggest me some link and tutorial
Thanks
You obviously need a pdf renderer/viewer. Since core Android OS does not provide one you will need a 3rd party one.
Take a look at http://andpdf.sourceforge.net/