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/
Related
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 am trying to implement reading a PDF within an Android app. I want to hide particular words from it.
I have downloaded a PDF viewer library. It opens properly but am not sure whether it is possible to hide words in that document.
Is there any library available that can do this?
Please help me!
Thanks in advance.
May be you are using muPDF Library and seriously muPDF or other libraries which renders PDF uses Images for rendering data they are not in text format so the modifications you want will be pretty hard to do so.
You may use iText Library for this, itext Library can extract the text from PDF and then you show the text as you want.
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 want to show pdf file in android, but this must work without Internet connection and other appliacation. Can I show pdf file in webView or other view?
Yes you can show your PDF to your custom view. For, this you've to use one External Jar file for that. I've already answered like similar to your question. Just check it out.
Hope this helps you.
Using another app to display your PDFs is a really nice way to do it. Unless you have superiors forcing you to avoid other apps, I'd do it that way. There are good, free pdf viewing apps available so it won't cost your users anything.
The transition when opening a pdf in another app is pretty seamless and it's not always obvious that another app is being used.
The alternative, as SpK said, is to use a jar and write the extra pdf viewing functionality that you need. This is a much harder way to do it.
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.