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);
Pdf Viewer library for Android
Overview
Comments
-
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.
-
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
-
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? }
-
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.
-
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?
-
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
-
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
-
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.
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
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
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
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
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
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
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
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
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 { ..
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
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
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
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
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
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
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
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.
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
[] 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