[英]How can i open PDF file from SdCard in my Application programmatically but not in device installed PDFViewer?
I Have used many of library but those all are Useless , I have also check weather the PDF file can be opened in Web-view By converting my URI to Html code using ContenProvider but that also isn't worked for me . 我已经使用了许多库,但是都没用,我还检查了可以在Web视图中打开PDF文件的情况,方法是使用ContenProvider将URI转换为HTML代码,但这对我来说不起作用。
I have used libraries like 我用过像
So, please if anyone have faced this problem or have solution for this problem then Help me to solve this problem. 因此,如果有人遇到此问题或对此问题有解决方案,请帮助我解决此问题。
I solved it using PDFViewer library PDFViewer All you need to do is to: 我使用PDFViewer库PDFViewer解决了它,您所需要做的就是:
Define an Activity like follows: 定义一个活动,如下所示:
public class ViewerActivity 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; }
} }
Call Activity like follows: 呼叫活动如下:
Intent intent = new Intent(this, MainActivity.class); intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, FILE_PATH); startActivity(intent);
Where FILE_PATH is pdfFileLocation on your device. 其中FILE_PATH是设备上的pdfFileLocation。 Mine was like
我的就像
final String FILE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/test/com_handbook.pdf";
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.