Pdf Viewer library for Android

Overview
This is a packaging of the project "Android PDF Viewer" (http://andpdf.sourceforge.net/) into a reusable library to make PDF viewing easier from within your Android application.

Consistent with the Android PDF Viewer project, the licensing for the PdfViewer project is LGPL

Quickstart incorporating a PDF viewing activity into your project:

1) Add PdfViewer.jar into your project's build path

2) Copy the following drawable resources from PdfViewer/res/drawable into YourProject/res/drawable
     left_arrow.png
     right_arrow.png
     zoom_in.png
     zoom_out.png

3) Copy the following layout resources from PdfViewer/res/layout into YourProject/res/layout
     dialog_pagenumber.xml
     pdf_file_password.xml

4) Derive your PDF activity from net.sf.andpdf.pdfviewer.PdfViewerActivity

5) Using the default drawables and layouts:
     public int getPreviousPageImageResource() { return R.drawable.left_arrow; }
     public int getNextPageImageResource() { return R.drawable.right_arrow; }
     public int getZoomInImageResource() { return R.drawable.zoom_in; }
     public int getZoomOutImageResource() { return R.drawable.zoom_out; }
     public int getPdfPasswordLayoutResource() { return R.layout.pdf_file_password; }
     public int getPdfPageNumberResource() { return R.layout.dialog_pagenumber; }
     public int getPdfPasswordEditField() { return R.id.etPassword; }
     public int getPdfPasswordOkButton() { return R.id.btOK; }
     public int getPdfPasswordExitButton() { return R.id.btExit; }
     public int getPdfPageNumberEditField() { return R.id.pagenum_edit; }

6) Invoke your PdfViewActivity derived with the following code:
     Intent intent = new Intent(this, YourPdfViewerActivity.class);
     intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, "PATH TO PDF GOES HERE");
     startActivity(intent);
    
Comments
  • How to Open remote PDF ?

    How to Open remote PDF ?

    Hello, I am getting a url of the location where the PDF is stored. I want to open the pdf with the pdfviewer. Can I get the guideline to open it as currently I am saving the url in string and then I am passing the string as the path of the pdf to the Activity through the intent

    final Intent readPdf = new Intent(getApplicationContext(), PdfViewerActivity.class);
    readPdf.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    readPdf.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
    startActivity(readPdf);
    

    It shows me PDF does not exists but the pdf is available. please guide.

    opened by BYogesh 2
  • Problem showing pdf

    Problem showing pdf

    Hi, i was trying to use your library to show a pdf in my app ant it gives me that error...

    E/APV.PDFRenderer﹕ null java.lang.NullPointerException at android.graphics.Canvas.drawBitmap(Canvas.java:1195) at com.sun.pdfview.PDFRenderer.drawImage(PDFRenderer.java:390) at com.sun.pdfview.PDFImageCmd.execute(PDFPage.java:654) at com.sun.pdfview.PDFRenderer.iterate(PDFRenderer.java:685) at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101) at com.sun.pdfview.BaseWatchable.execute(BaseWatchable.java:263) at com.sun.pdfview.BaseWatchable.go(BaseWatchable.java:197) at com.sun.pdfview.PDFPage.getImage(PDFPage.java:237) at segesa.catalogo.VisorPDF$2.doInBackground(VisorPDF.java:117) at segesa.catalogo.VisorPDF$2.doInBackground(VisorPDF.java:73) at android.os.AsyncTask$2.call(AsyncTask.java:287) at java.util.concurrent.FutureTask.run(FutureTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856)

    Its gives me the correct number of pages, but it dosent show anything.

    The pdf im trying to open is in that url http://www.cealsa.com/folletoiphone/folletoiphone.pdf But im trying to open it locally, from my internal storage.

    Thanks

    opened by alo 1
  • CryptoCipher stackoverflow issue

    CryptoCipher stackoverflow issue

    i add a pdf file with pdfpassword in that class it gives Stackoverflow issues to me.

    at line 56

    @Override
    public void init(int mode, SecretKeySpec keySpec, IvParameterSpec Iv) {
        init(mode, keySpec, Iv); //why recursion?
    }
    
    opened by BarisCirika 1
  • Decrease Image Size

    Decrease Image Size

    How i can decrease image size without changing image's width and height. (I use curl page project on github). and also sun's pdf reader reads pdf so slow it affects page curl. So i use thread's to handling this problem. But there is a problem here, i must have 10 image to apply this algorithm. But Java's vm breaks project (out of memory error). I found only way change width and height, but page's can not readable (so small). Any idea for that problems?. Thanks for everything, and also sorry for bad English.

    opened by BarisCirika 1
  • PDFFile.getPage(int, boolean) incorrect page.

    PDFFile.getPage(int, boolean) incorrect page.

    If i use the getPage method i get the incorrect page. For example if there is a 10 page pdf file. getPage(0, true) - returns page 1 getPage(1, true) - returns page 1 getPage(2, true) - returns page 2 getPage(3, true) - returns page 3 ... getPage(9, true) - returns page 9 getPage(10, true) - java.lang.ArrayIndexOutOfBoundsException: length=10; index=10

    How do i get page 10?

    opened by StEaLtHmAn 0
  • PDF Keeps Loading

    PDF Keeps Loading

    Hello Joe,

    I have implemented this library, and It was working as expected Thanks!!, however it does not work well with the latest Android 7 OS (Nougat); the PDF file keeps loading, I have tried a direct path (file:///android_asset/) to the PDFs files, but it did not work. please advise.

    Thank you

    opened by juanito34 2
  • how to get new jar

    how to get new jar

    I have updated a method to get bitmap of pdf page which i want to use. but i am unable to get new jar .Please somebody could help me with this issue. how I am using it..txt

    opened by kushagrasaxenaknit 0
  • PDFAuthenticationFailureException

    PDFAuthenticationFailureException

    I'm using the PDFViewer library and I have the next System.err:

    12-28 17:27:03.866 32545-32545/com.... W/System.err: com.sun.pdfview.decrypt.PDFAuthenticationFailureException: Password failed authentication for both owner and user password
    12-28 17:27:03.874 32545-32545/com.... W/System.err:     at com.sun.pdfview.decrypt.StandardDecrypter.<init>(StandardDecrypter.java:200)
    12-28 17:27:03.874 32545-32545/com.... W/System.err:     at com.sun.pdfview.decrypt.PDFDecrypterFactory.createStandardDecrypter(PDFDecrypterFactory.java:316)
    12-28 17:27:03.874 32545-32545/com.... W/System.err:     at com.sun.pdfview.decrypt.PDFDecrypterFactory.createDecryptor(PDFDecrypterFactory.java:99)
    12-28 17:27:03.874 32545-32545/com.... W/System.err:     at com.sun.pdfview.PDFFile.readTrailer(PDFFile.java:1108)
    12-28 17:27:03.874 32545-32545/com.... W/System.err:     at com.sun.pdfview.PDFFile.parseFile(PDFFile.java:1420)
    12-28 17:27:03.882 32545-32545/com.... W/System.err:     at com.sun.pdfview.PDFFile.<init>(PDFFile.java:140)
    12-28 17:27:03.882 32545-32545/com.... W/System.err:     at com.....visor.xml.objects.Strip.renderToBitmap(Strip.java:332)
    

    The code is:

    @Nullable
        private static Bitmap renderToBitmap(InputStream inputStream) {
            Bitmap bitmap = null;
            try {
                byte[] decode = org.apache.commons.io.IOUtils.toByteArray(inputStream);
                ByteBuffer byteBuffer = ByteBuffer.wrap(decode);
                PDFPage mPdfPage = new PDFFile(byteBuffer, null).getPage(0);
                float width = mPdfPage.getWidth();
                float height = mPdfPage.getHeight();
                RectF clip = null;
                bitmap = mPdfPage.getImage((int) (width), (int) (height), clip, true, true);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return bitmap;
        }
    

    and has been found here.

    The exact line that the Androir Monitor says the problem is, is the next: PDFPage mPdfPage = new PDFFile(byteBuffer, null).getPage(0);

    Any suggestion? Thank you very much.

    opened by oscargrgm 0
Owner
Joe Blough
Joe Blough
A new canvas drawing library for Android. Aims to be the Fabric.js for Android. Supports text, images, and hand/stylus drawing input. The library has a website and API docs, check it out

FabricView - A new canvas drawing library for Android. The library was born as part of a project in SD Hacks (www.sdhacks.io) on October 3rd. It is cu

Antwan Gaggi 1k Dec 13, 2022
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique López Mañas 3.6k Dec 29, 2022
Android library providing bread crumbs to the support library fragments.

Hansel And Gretel Android library providing bread crumbs for compatibility fragments. Usage For a working implementation of this project see the sampl

Jake Wharton 163 Nov 25, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Dec 6, 2022
TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

Tan Jun Rong 2.6k Jan 5, 2023
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Txus Ballesteros 1.5k Jan 2, 2023
Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (https://github.com/romannurik/android-wizardpager)

Wizard Pager Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (ht

Julián Suárez 520 Nov 11, 2022
Make your native android Toasts Fancy. A library that takes the standard Android toast to the next level with a variety of styling options. Style your toast from code.

FancyToast-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ... ma

Shashank Singhal 1.2k Dec 26, 2022
Make your native android Dialog Fancy. A library that takes the standard Android Dialog to the next level with a variety of styling options. Style your dialog from code.

FancyAlertDialog-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ..

Shashank Singhal 350 Dec 9, 2022
A Tinder-like Android library to create the swipe cards effect. You can swipe left or right to like or dislike the content.

Swipecards Travis master: A Tinder-like cards effect as of August 2014. You can swipe left or right to like or dislike the content. The library create

Dionysis Lorentzos 2.3k Dec 9, 2022
A Material design Android pincode library. Supports Fingerprint.

LolliPin A Lollipop material design styled android pincode library (API 14+) To include in your project, add this to your build.gradle file: //Loll

Omada Health 1.6k Nov 25, 2022
Android Library to implement simple touch/tap/swipe gestures

SimpleFingerGestures An android library to implement simple 1 or 2 finger gestures easily Example Library The library is inside the libSFG folder Samp

Arnav Gupta 315 Dec 21, 2022
Useful library to use custom fonts in your android app

EasyFonts A simple and useful android library to use custom fonts in android apps without adding fonts into asset/resource folder.Also by using this l

Vijay Vankhede 419 Sep 9, 2022
Android library which allows you to swipe down from an activity to close it.

Android Sliding Activity Library Easily create activities that can slide vertically on the screen and fit well into the Material Design age. Features

Jake Klinker 1.3k Nov 25, 2022
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR. Android Sliding Up Panel This library provides a simp

Umano: News Read To You 9.4k Dec 31, 2022
An Android library supports badge notification like iOS in Samsung, LG, Sony and HTC launchers.

ShortcutBadger: The ShortcutBadger makes your Android App show the count of unread messages as a badge on your App shortcut! Supported launchers: Sony

Leo Lin 7.2k Dec 30, 2022
Android Library to build a UI Card

Card Library Travis master: Travis dev: Card Library provides an easy way to display a UI Card using the Official Google CardView in your Android app.

Gabriele Mariotti 4.7k Dec 29, 2022
A horizontal view scroller library for Android

View Flow for Android ViewFlow is an Android UI widget providing a horizontally scrollable ViewGroup with items populated from an Adapter. Scroll down

Patrik Åkerfeldt 1.8k Dec 29, 2022
[] Android library that provides a file explorer to let users select files on external storage.

aFileChooser - Android File Chooser aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1

Paul Burke 1.8k Jan 5, 2023