Android pdf reader

前提是你 提交于 2019-12-01 05:01:33

问题


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

回答1:


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

Link1

Link2

an awesome example

Link 4

Link 5




回答2:


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();



回答3:


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.



来源:https://stackoverflow.com/questions/13344304/android-pdf-reader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!