Android学习之浏览pdf文档
来源:互联网 发布:火炬之光2mac版多少钱 编辑:程序博客网 时间:2024/05/17 07:51
在浏览项目的时候,发现有这么一个不错的工具【android-pdfview】,直接可以像浏览txt文档一样浏览pdf文档,这里我贴一下代码,主要是给自己标记一下。
点我下载android-pdfview工具
在布局文件中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <include layout="@layout/a1_head" /> <com.joanzapata.pdfview.PDFView android:id="@+id/pdfView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#444444" /></LinearLayout>
然后在activity中:
public class PdfViewActivity extends BaseActivity implements OnPageChangeListener{private PDFView pdfView;private int pageNum=1;private String filePath = Environment.getExternalStorageDirectory().getPath() + "/myTest.pdf";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_pdf_view);copyFileToSdcard();setActivityHeaderTitle(R.string.data_activity_name);getHeaderLeftButton().setImageResource(R.drawable.icon_back);File file=new File(filePath);pdfView=(PDFView) findViewById(R.id.pdfView);pdfView.fromFile(file) .defaultPage(pageNum) .onPageChange(PdfViewActivity.this) .load();}@Overridepublic void onPageChanged(int page, int pageCount) {page=pageNum;}private void copyFileToSdcard() {InputStream inputstream = getResources().openRawResource(R.raw.ceshi);byte[] buffer = new byte[1024];int count = 0;FileOutputStream fos = null;try {fos = new FileOutputStream(new File(filePath));while ((count = inputstream.read(buffer)) > 0) {fos.write(buffer, 0, count);}fos.close();} catch (FileNotFoundException e1) {e1.printStackTrace();Toast.makeText(PdfViewActivity.this, "Check your sdcard", Toast.LENGTH_LONG).show();} catch (IOException e) {e.printStackTrace();}}}
1 1
- Android学习之浏览pdf文档
- Android使用js方案实现在线浏览pdf文档
- android 实现PDF浏览
- iOS 开发之 pdf 文档的加载与浏览的 4 种方式
- iOS开发之pdf文档的加载与浏览的4种方式
- iOS开发之pdf文档的加载与浏览的4种方式
- 怎样使用PDF阅读器浏览查看PDF文档
- android解析pdf文档
- android 打开pdf文档
- Android 阅读PDF文档
- PDF文档在线浏览防下载加密方案
- PDF文档在线浏览防下载加密方案
- 在Drupal7当中如何直接在线浏览PDF文档
- 在线浏览PDF之PDF.JS (附demo)
- 浏览器在线浏览PDF文件之pdf.js
- Android之图片浏览
- android学习笔记之在程序里浏览网页
- android学习轨迹之三:图片浏览+拨号程序总结
- 已经完成的app怎么修改项目名和bundle
- NHibernate从入门到精通系列(4)——持久对象的生命周期(上)
- linux基础编程 共享内存 使用内存映射接口mmap系统调用 blog.csdn.net/ghostyu/article/details/7736733
- A look at the PowerVR graphics architecture: Tile-based rendering
- 黑马程序员Activity 介绍
- Android学习之浏览pdf文档
- 如何在Win7下运行Sencha Touch 2 examples?
- 深入浅出的讲解傅里叶变换
- 关于cup cache的理解
- 关于opencv的实用性
- Win32 线程知识点梳理二
- Android Monkey之script脚本
- C#创建windows服务搭配定时器Timer使用实例
- Android应用开发环境配置-使用eclipse进行开发