Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitmap quality is too low even I m using ARGB_8888 #67

Open
imvikasrai opened this issue Jul 6, 2019 · 0 comments
Open

Bitmap quality is too low even I m using ARGB_8888 #67

imvikasrai opened this issue Jul 6, 2019 · 0 comments

Comments

@imvikasrai
Copy link

here is my code

public static Bitmap getImageFromPdf(Uri pdfUri, Context context) {
int pageNumber = 0;
PdfiumCore pdfiumCore = new PdfiumCore(context);

    try {
        ParcelFileDescriptor fd = context.getContentResolver().openFileDescriptor(pdfUri, "r");
        PdfDocument pdfDocument = pdfiumCore.newDocument(fd);
        pdfiumCore.openPage(pdfDocument, pageNumber);
        int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNumber);
        int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNumber);

       Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        pdfiumCore.renderPageBitmap(pdfDocument, bmp, pageNumber, 0, 0, width, height);

        // sendTitle(pdfiumCore, pdfDocument, listener1);
        pdfiumCore.closeDocument(pdfDocument); // important!
        return bmp;
    } catch (Throwable e) {
        e.printStackTrace();
        return null;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant