I am working on an application which require to open, read and view pdf in Android Application. I am having a pdf files in assets folder. By default android does not support pdf.
Is there any API which is used to open, read and view pdf files. These files are in Assets folder.
After two days hard work and doing a lot of R&D I have got little bit solution but few Queries still remaining.
I have used PdfViewer its a Library to display PDF in android. And below is my code
MainActivity
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, MyPdfViewerActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME,
"mnt/sdcard/sample.pdf");
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
MyPdfViewerActivity
public class MyPdfViewerActivity 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;
}
}
There is a query
It is taking time in loading Pdf page and there is no output coming. Screenshot of Emulator
Is there any solution how to resolve this problem?
Thanks!!