Welcome folks I am back with another blog post. Today in this post we will be looking at a library which allows you to embed PDF Documents in Kotlin Application. The library name is PdfView-Android. You can download the library from here:

Features

It can handle big files to embed in Android Application It is based on ImageView Element in Android It gives you ultimate performance in rendering complex and big size PDF Documents.

Demo

How to Use

In order to use this library you need a PDF File on the system. Then you can write this line of code to include it through this library and display the file in app.

findViewById<PDFView>(R.id.activityMainPdfView).fromAsset("paper.pdf").show()

Add to your project:

repositories { <...> jcenter() }

Add gradle dependency:

implementation "com.pdfview:pdfview-android:1.0.0"

Full Example Code

Layout File:

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <com.pdfview.PDFView android:id="@+id/activityMainPdfView" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.constraint.ConstraintLayout>

2) Java Code:

MainActivity.kt