/**
* Show pages by index
*/
private void showPage(int index) {
if (mPdfRenderer == null || mPdfRenderer.getPageCount() <= index) {
System.out.println("pdf render is null");
return;
}
// Make sure to close the current page before opening another one.
if (null != mCurrentPage) {
mCurrentPage.close();
}
// Use `openPage` to open a specific page in PDF.
mCurrentPage = mPdfRenderer.openPage(index);
// Important: the destination bitmap must be ARGB (not RGB).
if (pdfBitmap != null) {
mImageView.setImageBitmap(null);
pdfBitmap.recycle();
}
pdfBitmap = Bitmap.createBitmap(mCurrentPage.getWidth(), mCurrentPage.getHeight(),
Bitmap.Config.ARGB_8888);
// Here, we render the page onto the Bitmap.
// To render a portion of the page, use the second and third parameter. Pass nulls to get
// the default result.
// Pass either RENDER_MODE_FOR_DISPLAY or RENDER_MODE_FOR_PRINT for the last parameter.
mCurrentPage.render(pdfBitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
// We are ready to show the Bitmap to user.
mImageView.setImageBitmap(pdfBitmap);
updateUi();
}
PdfRendererBasicFragment.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:Android_365
作者:
评论列表
文章目录