Pdf in android without other applications - 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.

Related

How do I view an ipynb file on android?

I just want to view them not work on them so I don't mind an ipynb to PDF or HTML converter on android
I usually just convert them from my laptop or upload them to colab before printing them as PDF but those options aren't available to me right now, any app suggestions methods are welcome.
There are ipynb viewers available on playstore, although I have not tried them.
I generally just change the extension to txt from ipynb, but this will give you a bunch of currently useless information also.

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.

Android: how to load pdf within app?

I have:
First goal: figure out how to load a PDF from the internet and display it whithin my app
Second (maybe more complex) goal: download a pdf and display OFFLINE within my app
I looked for some solution on stackoverflow and on the Internet but I can't figure out how to implement it
For example I found Mupdf and the source code of some PDF viewer for Android but I'm quite confused: why is so difficult to display a "simple PDF"? Is there any Java library that will do it without incorporate external source code etc.?
Any suggestion is really appreciated.
Thanks in advance!
There are some libraries and sdk.
This might help you
http://www.qoppa.com/android/pdfsdk/
http://code.google.com/p/droidreader/

Opening files within an application instead of default file viewer

I'd like to open files such as photos, documents, music and video in my application. I've seen a lot of applications that open up the files in the device's default program for that filetype.
Is there a way to somehow view the files in my application without opening another application?
Reading files in Android is just as simple as any other Java application. Depending on what type of file you want to read and display, you will do different things, this question tells you how to read a text file. The principle for other types is about the same. For images, you can simply use BitmapFactory.decodeFile(). I don't have experience with video or audio, but MediaPlayer looks like a promising first step.
You can do it, but only by writing your own Activity that can handle that type of media. So it can be a lot of work, depending on what you want to do. HTML, images, video, and audio are relatively easy, but if you want to do something like view PDF or office documents, you're setting yourself up for a tremendous amount of coding. Probably better just to launch someone else's viewer to view the relevant content; that's how almost everyone does it on Android.

PDF reading on 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.

Categories

Resources