How do I put a .pdf
file in app
itself, and open it without having to download using its URL? It would all be offline. Once the app was installed, .pdf
would go along with it.
How do I put a .pdf
file in app
itself, and open it without having to download using its URL? It would all be offline. Once the app was installed, .pdf
would go along with it.
Android does not support PDF format, so it is necessary to use external libraries. One quite used is the AndroidPdfViewer .
Below is a step-by-step guide to using it
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);
Source: README.txt