Since most of us work with PDF documents every day, it is important for apps to be capable of supporting PDF files. As an app developer, you might need to support PDF files in your app.
At Cloud Academy, we added the support for PDF documents to our Android and iOS native mobile apps while we were focusing on our big project to achieve feature-parity between our mobile and web platforms. We wanted our users to have the complete experience of our platform — either while using their computers in their homes or on their mobile phones while traveling.
Before considering a custom solution for our PDF reader, we researched the existing third-party solutions, but none of them were appealing or suitable for our app.
In fact, if you don’t want to use a third-party application, you have three options to show these documents inside of your app:

Use a third-party library (such as the most starred one on GitHub).
Use a WebView along with a Google Docs link.
Implement your Pdf Viewer using PdfRenderer from the Android SDK.

But which option is the best bet?
Option 1: While using a third-party library could be the easiest solution, most of them bring a lot of native libraries inside our code and increases the APK size (the library I linked adds 16 MB to the size of your APK).
Option 2: This solution is highly unprofessional because you have no control over how to display the document.
Option 3: If you are developing for devices with API ≥ 21, you can easily create a viewer for your document with less than 150 lines of code by using PdfRenderer and a new entry of 2019, ViewPager2.
Based on our testing, we selected option 3. In the article, I’ll explain how we implemented PDF Viewer using PdfRenderer and ViewPager2 in our mobile and web

View Entire Article on