Coder Social home page Coder Social logo

joanzapata / android-pdfview Goto Github PK

View Code? Open in Web Editor NEW
2.8K 160.0 788.0 13.98 MB

[DEPRECATED] A fast PDF reader component for Android development

Home Page: http://joanzapata.com/android-pdfview/

License: GNU General Public License v3.0

Java 100.00%

android-pdfview's Introduction

This project is no longer maintained.

You can find a good replacement here, which is a fork relying on Pdfium instead of Vudroid/MuPDF for decoding PDF files, allowing it to use the Apache License 2.0 which gives you much more freedom.


Android Arsenal

Screenshot of the sample app

Android PDFView is a library which provides a fast PDFView component for Android, with animations, gestures, and zoom. It's based on VuDroid for decoding the PDF file.

Get it

Android PDFView is available in Maven Central.

<dependency>
	<groupId>com.joanzapata.pdfview</groupId>
	<artifactId>android-pdfview</artifactId>
	<version>1.0.4</version>
	<type>apklib</type>
</dependency>

Or via gradle:

compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'

Include PDFView in your layout

<com.joanzapata.pdfview.PDFView
        android:id="@+id/pdfview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

Load a PDF file

pdfView.fromAsset(pdfName)
    .pages(0, 2, 1, 3, 3, 3)
    .defaultPage(1)
    .showMinimap(false)
    .enableSwipe(true)
    .onDraw(onDrawListener)
    .onLoad(onLoadCompleteListener)
    .onPageChange(onPageChangeListener)
    .load();
  • pages is optional, it allows you to filter and order the pages of the PDF as you need
  • onDraw is also optional, and allows you to draw something on a provided canvas, above the current page

License

Copyright 2013-2015 Joan Zapata

This file is part of Android-pdfview.

Android-pdfview is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Android-pdfview is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Android-pdfview.  If not, see <http://www.gnu.org/licenses/>.

android-pdfview's People

Contributors

alexbeville avatar geovie avatar joanzapata avatar johan12345 avatar kisty avatar matteinn avatar paulklauser avatar stefaneng avatar uscheller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-pdfview's Issues

error

Caused by: java.lang.UnsatisfiedLinkError: Native method not found: main.java.org.vudroid.pdfdroid.codec.PdfDocument.open:(ILjava/lang/String;Ljava/lang/String;)J

Is it possible to import the lib into Eclipse IDE?

Hi,

I am planing to use this library in one of my android app. And i am using Eclipse as my IDE. I tried to import library project, but it seem to have errors like package name problem. Even though i fix that, it shows org.vudroid.core.VuDroidLibraryLoader not found. If you could guide in this, it would be great. And its also great if you could provide JAR directly in downloads.

Thread safety issue

See #46

I ran into a regular crash when i was using the component to display various pdf file : on the left pane the name of the file and when the user click on a name, the pdf is displayed on the right.
Switching quickly between files to display led me into a RunTimeException in the function :

static PdfPage createPage(long dochandle, int pageno){
return new PdfPage(open(dochandle, pageno), dochandle);
}

in org.vudroid.pdfdroid.codec.PdfPage.
A little investigation led me to find that this happened when two threads was calling this function at the same time.

pdf file is not visible in the sample.

Hi ,

I have donwloaded and have configured the sample also with actionbarsherlock and annotations. But after opening app it simpley shows while page. its not showing the menu options also . please suggest.

Thanks,
Rajesh
device-2013-05-31-181223

Please response as soon as possible.

PDF rendering issues

Hi Joan,

first of all - thank you for this great library.

I have an issue with the PDF rendering when I zoom in.

Please take a look at the attached screenshot.

Do you have an idea why this problem occurs?

screenshot_2014-07-03-10-35-56

Use TextureView for API level 14+

Initially adviced by Romain Guy

Because a SurfaceView’s content does not live in the application’s window, it cannot be transformed (moved, scaled, rotated) efficiently. This makes it difficult to use a SurfaceView inside a ListView or a ScrollView. SurfaceView also cannot interact properly with some features of the UI toolkit such as fading edges or View.setAlpha().
TextureView creates a regular View instead of a new window and can therefore be translated, animated, etc... and easily added on components like lists.

Android 4.0 Graphics and Animations

TextureView is only available from API level 14, so I'd need to externalize rendering code and switch implementations regarding the OS version (I should probably check the hardware acceleration too).

Does not work with Android Studio

Hi @JoanZapata, I have already spent too long trying to get the Vudroid.so dep included in my project's build. I recommend testing the pdfview with AS and seeing if you can come to a solution, as it stands now it is broken because at run time the Vudroid.so lib is not loaded.

Crash on document load

E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: it.programmatica.reader, PID: 4942
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:300)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
     Caused by: java.lang.UnsatisfiedLinkError: Couldn't load vudroid from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/it.programmatica.reader-2.apk"],nativeLibraryDirectories=[/data/app-lib/it.programmatica.reader-2, /vendor/lib, /system/lib]]]: findLibrary returned null
            at java.lang.Runtime.loadLibrary(Runtime.java:358)
            at java.lang.System.loadLibrary(System.java:526)
            at org.vudroid.core.VuDroidLibraryLoader.load(VuDroidLibraryLoader.java:13)
            at org.vudroid.pdfdroid.codec.PdfContext.<clinit>(PdfContext.java:13)
            at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:50)
            at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:31)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)

thanks

AAR on Maven Central

It appears an apklib is uploaded to maven.org but not an aar. An aar would allow gradle to automatically import this dependancy.

Visibility of text

The library is good, however the text visibility is poor even when zooming.
Are you has a solution?

Wrong License

Please correct me if i´m wrong but i think that this library is not allowed to use the apache v2 license.

Since parts of vudroid´s source are used, which is licensed under GLP v3, it must be licensed under GLP too.

Application crashes Open "Incomplete PDF"

Hi i ran into problem, when i try to open a pdf which is remaining some part downloaded, the application crashes

02-18 14:58:52.749: E/AndroidRuntime(32014): FATAL EXCEPTION: AsyncTask #3 02-18 14:58:52.749: E/AndroidRuntime(32014): Process: com.sfworx.droids.it_ebooks, PID: 32014 02-18 14:58:52.749: E/AndroidRuntime(32014): java.lang.RuntimeException: An error occured while executing doInBackground() 02-18 14:58:52.749: E/AndroidRuntime(32014): at android.os.AsyncTask$3.done(AsyncTask.java:300) 02-18 14:58:52.749: E/AndroidRuntime(32014): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 02-18 14:58:52.749: E/AndroidRuntime(32014): at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 02-18 14:58:52.749: E/AndroidRuntime(32014): at java.util.concurrent.FutureTask.run(FutureTask.java:242) 02-18 14:58:52.749: E/AndroidRuntime(32014): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 02-18 14:58:52.749: E/AndroidRuntime(32014): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 02-18 14:58:52.749: E/AndroidRuntime(32014): at java.lang.Thread.run(Thread.java:841) 02-18 14:58:52.749: E/AndroidRuntime(32014): Caused by: java.lang.RuntimeException: PDF file is corrupted 02-18 14:58:52.749: E/AndroidRuntime(32014): at org.vudroid.pdfdroid.codec.PdfDocument.open(Native Method) 02-18 14:58:52.749: E/AndroidRuntime(32014): at org.vudroid.pdfdroid.codec.PdfDocument.openDocument(PdfDocument.java:28) 02-18 14:58:52.749: E/AndroidRuntime(32014): at org.vudroid.pdfdroid.codec.PdfContext.openDocument(PdfContext.java:18) 02-18 14:58:52.749: E/AndroidRuntime(32014): at org.vudroid.core.DecodeServiceBase.open(DecodeServiceBase.java:59) 02-18 14:58:52.749: E/AndroidRuntime(32014): at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:49) 02-18 14:58:52.749: E/AndroidRuntime(32014): at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:1) 02-18 14:58:52.749: E/AndroidRuntime(32014): at android.os.AsyncTask$2.call(AsyncTask.java:288) 02-18 14:58:52.749: E/AndroidRuntime(32014): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 02-18 14:58:52.749: E/AndroidRuntime(32014): ... 3 more

Set orientation of the pdf

horizontal
Right now, some pdfs are displayed in portrait mode while the device is in landscape (see image). I guess this is due to the calculations (width height of a page). But this is pretty strange behaviour I think so it would be nice if there was an extra setting that forces all pages to be displayed horizontal or vertical.

So that the pages are readable in the same orientation the device is in..

pdfView.fromFile(file) not working. my app goes crash.

Hi i'm using your PDF viewer and my goes crash .Please help ASAP. Below is my application crash log.

07-02 08:44:44.202: E/AndroidRuntime(32162): java.lang.RuntimeException: error loading page
07-02 08:44:44.202: E/AndroidRuntime(32162): at org.vudroid.pdfdroid.codec.PdfPage.open(Native Method)
07-02 08:44:44.202: E/AndroidRuntime(32162): at org.vudroid.pdfdroid.codec.PdfPage.createPage(PdfPage.java:55)
07-02 08:44:44.202: E/AndroidRuntime(32162): at org.vudroid.pdfdroid.codec.PdfDocument.getPage(PdfDocument.java:18)
07-02 08:44:44.202: E/AndroidRuntime(32162): at org.vudroid.core.DecodeServiceBase.getPage(DecodeServiceBase.java:175)
07-02 08:44:44.202: E/AndroidRuntime(32162): at org.vudroid.core.DecodeServiceBase.getPageWidth(DecodeServiceBase.java:214)
07-02 08:44:44.202: E/AndroidRuntime(32162): at com.joanzapata.pdfview.PDFView.loadComplete(PDFView.java:626)
07-02 08:44:44.202: E/AndroidRuntime(32162): at com.joanzapata.pdfview.DecodingAsyncTask.onPostExecute(DecodingAsyncTask.java:58)
07-02 08:44:44.202: E/AndroidRuntime(32162): at com.joanzapata.pdfview.DecodingAsyncTask.onPostExecute(DecodingAsyncTask.java:1)

GPL 3 license

Hi,

I found your library very useful. Great work :)

I am developing a commercial application where i want to use your library. Since you are using GPL 3 license, i understand that if i use your library, i have to expose source of my application also. Is this understanding correct ?

I can't expose source code of my application, is there different license i can use to use your library ? e.g. http://www.apache.org/licenses/LICENSE-2.0 or http://creativecommons.org/licenses/by/2.5/ ?

Thanks a lot for your time. Looking forward for a positive reply.

Regards,
Ashwani Kr Sharma

jump to page

is it possible to jump to a specific page? (edit: jumpToPage())

Help me

hi guys , can you help me becouse i'm newbie
i improt android-pdfview on eclipse but ,i had Mistakes :
swwwans titre
thnx...

Libray fails to render specific PDF files

Hi,
For some reason, I am unable to render some particular files.
Here is the link to the files -
https://drive.google.com/folderview?id=0ByOGTe_MnFxcMW8wdEJrTnEtaTA

I was earlier thinking that the library was having issues in rendering all files of large sizes.
This issue is not there for every file or above a specified file limit. I have tried many other files of 30MB - 46 MB (one file of 58MB also got rendered) and they got rendered pretty well. But, I am not sure why is it not rendering these specific files.
It just tries to load this file and the the Activity goes black and nothing is displayed at all.
Can you look into this and see what is the issue with rendering of this file?

How to change swipe orientation to RTL ?

Hello guys,

In order to read an arabic book, i need to make my pdf swipe orientation to RTL,
So is there some config to make this change or we need to develop this task ?

Thanks in advance ...

PDF file is corrupted

java.lang.RuntimeException: An error occured while executing doInBackground()
Caused by: java.lang.RuntimeException: PDF file is corrupted
at:
static PdfDocument openDocument(String fname, String pwd)
{
return new PdfDocument(open(FITZMEMORY, fname, pwd));
}
in PdfDocument class

Working sample project for eclipse?

Hi, this library looks very promising.
I see there are posts about using it with eclipse but I could not find a working solution.
I added "android-pdfview" as a libary project into eclipse and then I added it to my own project. Everything seems to be fine and eclipse does not complain.

However as soon as I try to open a pdf my app crashes (runtimeexception).

My code looks like this:
PDFView pdfView = (PDFView) findViewById(R.id.pdfview);
pdfView.fromAsset("test.pdf")
.defaultPage(1)
.load();

Getting each page..

Hello ,
Thanks for sharing great library project. How can I get each pdf page as independent bitmap. In this project two or three pages are rendering as one big bitmap.
Thanks in advance

Find a better DSL

Prerequisite for #8.

The current DSL forces to reconfigure the whole object.

java
pdfView.fromAsset(pdfName)
.pages(0, 2, 1, 3, 3, 3)
.defaultPage(1)
.showMinimap(false)
.enableSwipe(true)
.onDraw(onDrawListener)
.onLoad(onLoadCompleteListener)
.onPageChange(onPageChangeListener)
.load();


The only relevant part of it is:

``` java
pdfView.fromAsset(pdfName) // or fromFile(), fromXXX(), ...
    .pages(0, 2, 1, 3, 3, 3)
    .defaultPage(1)
    .onLoad(onLoadCompleteListener)
    .load();

Other methods should be available at any time, not only in the initialization phase.
This is related to #8 because setting the callbacks should be done on configuration change, but not load(), the methods need to be splited.

Double tap to zoom

Is it possible to double tap to zoom? The only thing it does is double tap to reset zoom.

Is it possible to set a LongClickListener

Is it possible to set a LongClickListener to a PDFView like this?

PDFView.setOnLongClickListener

or maybe the PDFView has its own method to do it?

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.