AndroidPdfViewer icon indicating copy to clipboard operation
AndroidPdfViewer copied to clipboard

When I use onRender(new OnRenderListener(), the PDF is not displayed

Open AlejandroGomz opened this issue 3 years ago • 1 comments

Hi,

when I use onRender(new OnRenderListener(), the PDF is not displayed. If I don't use the RenderListener, the PDF document is displayed. What am I doing wrong?

Android API 30 implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

    pdfView=findViewById(R.id.pdfv);
    pdfView.useBestQuality(true);
    pdfView.fromUri(uri)
            .onError(e -> Log.e(TAG, "openPDFFile Error: "+e))
            .nightMode(false)
            .onLoad(nbPages -> {
                Log.d(TAG, "openPDFFile..load completed");
            })
            .onRender(new OnRenderListener() {
                @Override
                public void onInitiallyRendered(int nbPages) {
                    Log.d(TAG, "openPDFFile..render completed nbPages: "+nbPages);
                    pdfView.fitToWidth(nbPages);
                }
            })
            .load();

It seems, that fitToWidth() makes some troubles, because onLoad() is faster then onRender()?

AlejandroGomz avatar Jun 29 '21 22:06 AlejandroGomz

Do not use the param nbPages, you have to use the page number that is visible at this moment

Basti189 avatar Sep 19 '22 21:09 Basti189