android获取PDF文件的缩略图

来源:互联网 发布:北京网络 编辑:程序博客网 时间:2024/05/17 07:10
最近做个开发区宣传app,需要展示pdf文件,界面需要缩略图。
使用pdfview插件,进行操作
代码为
private static Bitmap getPDFThumbnail(String filePath) {    PdfContext pdfContext =new PdfContext();    PdfDocument pdfDocument=(PdfDocument)pdfContext.openDocument(filePath);//path为要截图的pdf的路径,String类型      PdfPage pdfPage=(PdfPage)pdfDocument.getPage(1);//page为要截取的页数,int型      RectF rf = new RectF();//使用一个矩形去截图      rf.bottom = rf.right=(float)1.0;//上方与左方不指定,下方与右方指定为1.0的位置,即截下整幅图      Bitmap bitmap =pdfPage.renderBitmap(pdfPage.getWidth(),pdfPage.getHeight(),rf);//这个bitmap就是我们要截的图     return bitmap;}
阅读全文
0 0
原创粉丝点击