Skip to content

Pdfium-Based PDF Rendering Engine compatible with Android 4.4

License

Notifications You must be signed in to change notification settings

loilo-inc/loilo-pdf

Repository files navigation

loilo-pdf

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.

Compatibility

Currently >= 4.4 (API Level 19)

Usage

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);
        }
    }
}

Install

PdfRenderer is available on Marven Central.

via Gradle


dependencies {
  compile 'tv.loilo.pdf:pdfcompat:2.0.0'
}

Original Pdfium Library

This library is forked from original pdfium library in AOSP, version of refs/tags/android-7.1.1_r6.

LICENSE

Apache License Version 2.0