An Open Source PDF Rendering Library for Android based on pdfium @ AOSP.
This library was developed because of need for compatibility of PdfRenderer
class with previous version of android.
Currently >= 4.4 (API Level 19)
This library is fully compatible with PdfRenderer class which is available from Android 5.0 (lollipop).
// pdf file
File file = new File("file.pdf");
try (ParcelFileDescriptor fd = ParcelFileDescriptor.open(file,ParcelFileDescriptor.MODE_READ_ONLY);
PdfRendererCompat renderer = new PdfRendererCompat(fd);
) {
for (int i = 0; i < renderer.getPageCount(); i++) {
try(PdfRendererCompat.Page page = renderer.openPage(i)){
Bitmap out = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Matrix mat = new Matrix();
mat.setScale(2,2);
page.render(out, null, mat, PdfRendererCompat.Page.RENDER_MODE_FOR_DISPLAY);
}
}
}
PdfRenderer is available on Marven Central.
via Gradle
dependencies {
compile 'tv.loilo.pdf:pdfcompat:2.0.0'
}
This library is forked from original pdfium library in AOSP, version of refs/tags/android-7.1.1_r6.
Apache License Version 2.0