我正在实现某种杂志查看器(用于浏览类似于android库中的页面),它的内容取自pdf文件;页面必须是可缩放的。一开始,我试着使用那些pdf中单独的图片。我借了ImageViewTouch和ImageViewTouchViewPager。它工作得很好,但我不能在内存中保存超过3-4张大图片(OutOfMemory错误),所以实现不适合我。(我需要内存中的5张大图片加上大约50张小图片的内存来显示目录)
所以我决定用pdf文件。我尝试过用PdfViewer.jar显示pdf,但是当您试图放大或缩小时,这个PDFViewerActivity实现会丢失图片或文本。
你能建议我如何在android图库中显示我的pdf吗?或者,至少,请告诉我,如果您知道视图,哪些视图可以显示带有缩放选项的PDFPage?
编辑的:i不需要打开侧应用程序查看pdf。我需要在我的应用程序中播放它。
发布于 2013-08-12 06:50:10
你可以试试这个:
public static void openPdf(Context context, String filename) {
File targetFile = new File(filename);
Uri targetUri = Uri.fromFile(targetFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(targetUri, "application/pdf");
try {
context.startActivity(intent);
} catch (ActivityNotFoundException act ) {
Toast.makeText(context, "Please install a pdf reader to view help",Toast.LENGTH_LONG).show();
}
}
https://stackoverflow.com/questions/18180950
复制相似问题