4

I want to use Android pdf library http://andpdf.sourceforge.net/, but i have same error. Log:

 ST='file 'no file selected' not found'
 ST='reading page 1, zoom:1.0'

My classes:

public class Reader extends PdfViewerActivity {

 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; }
}

and

public class StartScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    Intent intent = new Intent(this, Reader.class);
     intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, "/sdcard/test.pdf");
     startActivity(intent);
}
}
Yuriy Aizenberg
  • 373
  • 9
  • 28
  • This library has a same problems with rendering :( Sometimes the pieces of pdf-file are not loaded. – Yuriy Aizenberg Nov 13 '12 at 12:39
  • did u see the last one i told u about it is work fine to me. check your pdf file maybe there is error when you download it or copy it. – Omarj Nov 14 '12 at 08:19

3 Answers3

4

Here some Google Code has some nice source code for reading pdf in android.

Link1

Link2

an awesome example

Link 4

Link 5

Omarj
  • 1,151
  • 2
  • 16
  • 43
1

Now we have this awesome library for PDF viewing:

https://github.com/JoanZapata/android-pdfview

It is really simple to use and has a lot of features:

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.

Just include the view in your XML and use it as follows:

pdfView.fromAsset(pdfName)
    .pages(0, 2, 1, 3, 3, 3)
    .defaultPage(1)
    .showMinimap(false)
    .enableSwipe(true)
    .onDraw(onDrawListener)
    .onLoad(onLoadCompleteListener)
    .onPageChange(onPageChangeListener)
    .load();
Vedant Agarwala
  • 18,146
  • 4
  • 66
  • 89
  • 1
    Heads up: It's a GPL library. Might not be appropriate for all projects. – steipete May 03 '16 at 15:16
  • 1
    @steipete Which essentially makes it useless for MOST android projects, as you have to make code of your whole app available. This does not appear to be the issue with the library itself, but with one of its dependencies. Author said: "Unfortunately my library is using VuDroid which uses MuPDF for rendering pdf pages. muPDF is licensed with GPL3 so I'm forced to use the same. " – CoolCodeBro May 14 '16 at 18:33
0

With PdfViewPager you can load and display PDF files easily. All the code you need is:

PdfViewPager pdfViewPager = new PDFViewPager(this, "sample.pdf");
setContentView(pdfViewPager);

Or you can embed it in your layout like this:

<es.voghdev.pdfviewpager.library.PDFViewPager
  android:id="@+id/pdfViewPager"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:assetFileName="sample.pdf"/>

Have a look at the lib if you want to know more.

voghDev
  • 5,641
  • 2
  • 37
  • 41
  • Showing this error when zooming pdf out pls help I am using same PDFViewerPager you mentioned above Process: com.pdffilereader, java.lang.IllegalArgumentException: pointerIndex out of range at android.view.MotionEvent.nativeGetAxisValue(Native Method) at android.view.MotionEvent.getX(MotionEvent.java:2057) – Sunil Chaudhary Jul 11 '16 at 12:38