VOOZH about

URL: https://www.geeksforgeeks.org/kotlin/extract-data-from-pdf-file-using-android-jetpack-compose/

⇱ Extract Data From PDF File using Android Jetpack Compose - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Extract Data From PDF File using Android Jetpack Compose

Last Updated : 23 Jul, 2025

PDF files are used in many android applications for displaying data in the form of images, text as well as graphics. Many applications are also required to get the data from this PDF file and display this data within the android application. So for extracting the data from PDF file pdf reader is used which is used to read pdf and get the data from PDF file.

In this article, we will be building a simple application in which we will be extracting data from PDF files in Android using Jetpack Compose

Step by Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.

Step 2: Adding dependency in build.gradle file 

Navigate to Gradle Scripts > build.gradle.kts (Module :app) and add the below dependency

dependencies {
...
implementation ("com.itextpdf:itextg:5.5.10")
}

After adding this dependency simply sync your project to install it. 

Refer to the following github repo to read the docs: https://github.com/itext/itextpdf

Step 3: Adding PDF file to your project

As we are extracting data from PDF files, so we will be adding PDF files to our app. To add PDF files to your app, we must create the raw folder first. Please refer to Resource Raw Folder in Android Studio to create a raw folder in android. After creating a new raw directory copy and paste your PDF file inside that β€œraw” folder.

You can download a sample pdf from here.

Step 4: Working with the MainActivity.kt file

Go to the MainActivity.kt file and refer to the following code. Comments are added inside the code to understand the code in more detail.

MainActivity.kt:


Output: 


Comment
Article Tags:

Explore