🌐
Nutrient
nutrient.io › blog › sdk › how to build an android pdf viewer
Build an Android PDF viewer using Nutrient: A step-by-step guide
1 month ago - ... The next few sections will walk you through the getting started process. Launch Android Studio and select New Project. Navigate to File > New > New Project… to start creating ...
🌐
Medium
medium.com › @generalfocus1 › build-your-own-android-pdf-reader-from-scratch-using-android-studio-ac65601eb90
Build Android PDF Reader From Scratch Using Android Studio | by Oyinkansola Olabode | Medium
April 6, 2020 - But this tutorial will focus majorly on the first which is how to build an inbuilt pdf reader. I will assume the reader of this tutorial has basic android development skill which will make me skip some part such as new project creation on android studio; activity selection and other fundamentals of creating an android studio project. After creating your android studio project, add the dependency below to your gradle file · implementation 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.5'
People also ask

More about PdfActivity

PdfActivity is a public class that extends AppCompatActivity(opens in a new tab) and implements [PdfUi], [PdfActivityListener], and PdfActivityComponentsApi. It’s an activity with fully integrated views and behavior, and it can be invoked by the simple helper methods [showDocument][showdocument]) and [showImage][showimage]).

🌐
nutrient.io
nutrient.io › blog › sdk › how to build an android pdf viewer
Build an Android PDF viewer using Nutrient: A step-by-step guide
What is an intent in Android?

Intents are messages you pass to the Android OS. They describe actions you want the system to perform on your behalf. After describing an intent, you pass it to the OS and act on the result. Usually, the result is passed to a callback function.

🌐
nutrient.io
nutrient.io › blog › sdk › how to build an android pdf viewer
Build an Android PDF viewer using Nutrient: A step-by-step guide
What’s a request code used for in Android?

In Android, request codes help identify intents and their corresponding results. The best place to declare a request code is in a separate file that holds all your constants.

🌐
nutrient.io
nutrient.io › blog › sdk › how to build an android pdf viewer
Build an Android PDF viewer using Nutrient: A step-by-step guide
🌐
ComPDF
compdf.com › blog › build-an-android-pdf-viewer-or-editor-in-java
How to Build a Java Android PDF Viewer or Editor
ComPDF also provides the guides to build an Android PDF Editor. 1. Copy a PDF document into the assets directory of your Android project. For example, import the file Quick Start Guide.pdf to the path src/main/assets.
🌐
Reintech
reintech.io › blog › implementing-pdf-reader-app-android-using-pdfrenderer
Implementing a PDF reader app for Android using PDFRenderer | Reintech media
February 3, 2026 - Create a new Android project in Android Studio with the "Empty Activity" template. The minimum SDK should be set to API 21 (Android 5.0) or higher to ensure compatibility with PDF rendering capabilities.
🌐
Blogger
devofandroid.blogspot.com › 2018 › 04 › pdf-reader-app-android-studio-tutorial.html
PDF reader app - Android Studio Tutorial
July 4, 2023 - A blog web site to learn the Android ... scratch to professional in Java and Kotlin using Android Studio. ... This tutorial is about: ✓Create PDF app. ✓Display Specific or all pages from PDF ✓Display PDF from Assets folder. ✓Add padding between pages ✓Passwords ✓Scroll PDF pages vertically or Swipe horizontally. implementation 'com.github.barteksc:android-pdf-viewer:3.0.0-...
🌐
Android Developers
developer.android.com › camera & media dev center › implement a pdf viewer
Implement a PDF viewer | Android media | Android Developers
November 17, 2025 - The activity that hosts PdfViewerFragment must extend AppCompatActivity. In the onCreate() method of the activity, set the content view to the layout you created, and initialize any necessary UI elements.
🌐
GeeksforGeeks
geeksforgeeks.org › android › how-to-create-dynamic-pdf-viewer-in-android-with-firebase
How to Create Dynamic PDF Viewer in Android with Firebase? - GeeksforGeeks
Step 3: Add the dependency for PDF Viewer in build.gradle file · Navigate to the app > Gradle Scripts > build.gradle file and add below dependency in it. implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
Published   July 23, 2025
🌐
YouTube
youtube.com › watch
Add PDF Files in Android Apps | PDF Viewer | Android Studio - YouTube
This is a tutorial about how to add or show pdf files in android apps. PDF View Library: https://github.com/barteksc/AndroidPdfViewerJoin our Facebook Group ...
Published   January 24, 2021
Find elsewhere
🌐
YouTube
youtube.com › watch
PdfViewer App - Load Local Pdfs From Device ( Android Studio ) - YouTube
In This Video, I am gonna show you how to create pdf viewer app with library . Load local pdfs from device to our app.Connect with us -Follow me on Instagram...
Published   June 10, 2023
🌐
YouTube
youtube.com › btech days
Make a PDF Reader App | Complete App | Android Project | Android Studio - YouTube
#donate#btechdays#purchaseDONATE US:-PayPal :- https://www.paypal.me/btechdaysUpi ID :- btechdays.care@oksbi-------------------------------------------------...
Published   June 5, 2021
Views   24K
Top answer
1 of 1
2

You can view a pdf file in an android project in different ways. I will describe some of them here-

1. Using Library: Steps are below:

Installation Add to build.gradle: implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
ProGuard If you are using ProGuard, add following rule to proguard config file:
-keep class com.shockwave.**
Include PDFView in your layout
<com.github.barteksc.pdfviewer.PDFView android:id="@+id/pdfView" android:layout_width="match_parent" android:layout_height="match_parent"/>
Further link is here
2. Load pdf url into webview:

webview = (WebView)findViewById(R.id.webview);
    progressbar = (ProgressBar) findViewById(R.id.progressbar);
    webview.getSettings().setJavaScriptEnabled(true);
    String filename = file_url_with_name;
    webview.loadUrl(file_url + filename);

    webview.setWebViewClient(new WebViewClient() {

        public void onPageFinished(WebView view, String url) {
            // do your stuff here
            progressbar.setVisibility(View.GONE);
        }
    });


3. Manually show PDF file into Imageview

// Example for creating manual PDF viewer into imageview used butterknife view binding<br/>

public class PdfRenderActivity extends AppCompatActivity {

    @BindView(R.id.pdf_image) ImageView imageViewPdf;
    @BindView(R.id.button_pre_doc) FloatingActionButton prePageButton;
    @BindView(R.id.button_next_doc) FloatingActionButton nextPageButton;

    private static final String FILENAME = "report.pdf";

    private int pageIndex;
    private PdfRenderer pdfRenderer;
    private PdfRenderer.Page currentPage;
    private ParcelFileDescriptor parcelFileDescriptor;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pdf_render);
        ButterKnife.bind(this);
        pageIndex = 0;
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onStart() {
        super.onStart();
        try {
            openRenderer(getApplicationContext());
            showPage(pageIndex);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onStop() {
        try {
            closeRenderer();
        } catch (IOException e) {
            e.printStackTrace();
        }
        super.onStop();
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @OnClick(R.id.button_pre_doc)
    public void onPreviousDocClick(){
        showPage(currentPage.getIndex() - 1);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @OnClick(R.id.button_next_doc)
    public void onNextDocClick(){
        showPage(currentPage.getIndex() + 1);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void openRenderer(Context context) throws IOException {
        // In this sample, we read a PDF from the assets directory.
        File file = new File(context.getCacheDir(), FILENAME);
        if (!file.exists()) {
            // Since PdfRenderer cannot handle the compressed asset file directly, we copy it into
            // the cache directory.
            InputStream asset = context.getAssets().open(FILENAME);
            FileOutputStream output = new FileOutputStream(file);
            final byte[] buffer = new byte[1024];
            int size;
            while ((size = asset.read(buffer)) != -1) {
                output.write(buffer, 0, size);
            }
            asset.close();
            output.close();
        }
        parcelFileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
        // This is the PdfRenderer we use to render the PDF.
        if (parcelFileDescriptor != null) {
            pdfRenderer = new PdfRenderer(parcelFileDescriptor);
        }
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void closeRenderer() throws IOException {
        if (null != currentPage) {
            currentPage.close();
        }
        pdfRenderer.close();
        parcelFileDescriptor.close();
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void showPage(int index) {
        if (pdfRenderer.getPageCount() <= index) {
            return;
        }
        // Make sure to close the current page before opening another one.
        if (null != currentPage) {
            currentPage.close();
        }
        // Use `openPage` to open a specific page in PDF.
        currentPage = pdfRenderer.openPage(index);
        // Important: the destination bitmap must be ARGB (not RGB).
        Bitmap bitmap = Bitmap.createBitmap(currentPage.getWidth(), currentPage.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.
        currentPage.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
        // We are ready to show the Bitmap to user.
        imageViewPdf.setImageBitmap(bitmap);
        updateUi();
    }

    /**
     * Updates the state of 2 control buttons in response to the current page index.
     */
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void updateUi() {
        int index = currentPage.getIndex();
        int pageCount = pdfRenderer.getPageCount();
        prePageButton.setEnabled(0 != index);
        nextPageButton.setEnabled(index + 1 < pageCount);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public int getPageCount() {
        return pdfRenderer.getPageCount();
    }

}

Doc is here

🌐
Quora
quora.com › How-can-I-develop-a-PDF-viewer-app-using-Android-Studio
How to develop a PDF viewer app using Android Studio - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
DEV Community
dev.to › youna12345 › how-to-build-an-android-pdf-viewer-or-editor-in-java-104p
How to Build an Android PDF Viewer or Editor in Java - DEV Community
August 2, 2023 - For example, import the file Quick Start Guide.pdf to the path src/main/assets. 2. Create a new Empty Activity under your package, and set the activity name to MainActivity. Android Studio will automatically generate a source file called MainActivity.java and a layout file called activity_main.xml.
🌐
Android Developers
developer.android.com › core areas › ui › views › implement a pdf viewer
Implement a PDF viewer | Views | Android Developers
Step-by-step guide to implementing a PDF viewer in your Android application using the Jetpack PdfViewerFragment.
🌐
Medium
medium.com › @programmingAi › how-to-create-your-own-pdf-editor-for-android-step-by-step-a9a09b4d12fb
How to Create Your Own PDF Editor for Android Step by Step | by Alamghir | Medium
December 6, 2024 - The iText library (which is a powerful PDF manipulation library for Android). Start by creating a new Android project in Android Studio:
🌐
Apryse
apryse.com › blog › build-an-android-pdf-viewer-using-java
How to Build an Android PDF Viewer Using Java | Apryse
November 21, 2018 - As you can see, using PdfRenderer is an easy way to create a simple single-page PDF viewer in your Android app. However, if you need users to interact with a PDF document, then I'm afraid you're out of luck.
🌐
ComPDF
compdf.com › blog › build-an-android-pdf-viewer-or-editor-in-kotlin
Build an Android PDF Viewer or Editor in Kotlin | ComPDF
July 9, 2025 - When you finish the steps in this part, you will get an Android PDF viewer below: Copy a PDF document into the assets directory of your Android project. For example, import the file Quick Start Guide.pdf to the path src/main/assets.
🌐
Mindorks
blog.mindorks.com › how-to-open-a-pdf-file-in-android-programmatically
How to open a PDF file in Android programmatically? - MindOrks
June 17, 2019 - In our example, we are going to cover four different cases: ... So, for the first point, we will use WebViewActivity and for 2nd, 3rd, and 4th point, we will be using PdfViewActivtiy . Create two activities named WebViewActivtiy and PdfViewActivity ...
🌐
Android Developers
developer.android.com › camera & media dev center › android pdf viewer
Android PDF viewer | Android media | Android Developers
The PDF viewer library (androidx.pdf), provides an embeddable PDF viewer UI that enables users to do the following: ... You can create a full-featured PDF experience by integrating the Jetpack library APIs or using the framework APIs directly.