【发布时间】:2014-03-22 13:02:42
【问题描述】:
我使用了很多库,但这些都是无用的,我还检查了 PDF 文件是否可以在 Web 视图中打开通过使用 ContenProviderURI 转换为 Html 代码/strong> 但这对我也不起作用。
我使用过类似的库
- PDF 查看器
- MuPDF 库
- 还有更多...
所以,如果有人遇到过这个问题或有解决这个问题的方法,请帮我解决这个问题。
【问题讨论】:
标签: android pdf android-webview
我使用了很多库,但这些都是无用的,我还检查了 PDF 文件是否可以在 Web 视图中打开通过使用 ContenProviderURI 转换为 Html 代码/strong> 但这对我也不起作用。
我使用过类似的库
所以,如果有人遇到过这个问题或有解决这个问题的方法,请帮我解决这个问题。
【问题讨论】:
标签: android pdf android-webview
我使用 PDFViewer 库 PDFViewer 解决了它 您需要做的就是:
如下定义一个Activity:
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; }
}
调用Activity如下:
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, FILE_PATH);
startActivity(intent);
其中 FILE_PATH 是您设备上的 pdfFileLocation。 我的就像
final String FILE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/test/com_handbook.pdf";
希望这会有所帮助。
【讨论】: