MCPcopy Index your code
hub / github.com/ComPDFKit/compdfkit-pdf-sdk-android

github.com/ComPDFKit/compdfkit-pdf-sdk-android @v2.6.9

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.6.9 ↗ · + Follow
4,724 symbols 16,279 edges 500 files 276 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ComPDF SDK for Android (PDF Library)

As part of the KDAN ecosystem, ComPDF SDK for Android enables developers to quickly and seamlessly integrate advanced PDF functionalities—such as PDF generating viewing, editing, annotating, and signing—into any Android application.

The ComPDF Android PDF Library provides an easy-to-use Java API that allows direct access to a wide range of PDF features without the need for complex configurations.

If you find ComPDF SDK useful, please consider giving us a ⭐ Star on GitHub — it helps us grow and improve! Got questions or ideas? Join the conversation in our Discussions.

Android Demo GIF

Why ComPDF SDK for Android?

  • Easy to Integrate: Integrate PDF functionalities easily with our powerful SDK and clear documentation and guides with few lines of code.

  • Fully Customizable UI: Design a unique interface for your products with fully customizable UI source code by a high-performing SDK.

  • Comprehensive PDF Features: Supports generation, viewing, annotation, page editing, content editing, conversion, OCR, redaction, signing, forms, parsing, measurement, compression, comparison, color separation, batch processing, and more.

  • Faster Time-to-Market: Comprehensive SDK libraries save your time and expenses and roll out your applications and projects.

  • High-quality Service: We provide 24/7 professional one-to-one technical support, including onsite service and remote assistance via phone and email.

Table of Contents

Supported Features

Viewer: Fast and smooth PDF rendering and viewing

  • Display Modes - single/double page, vertical & horizontal scrolling, cover mode, crop mode
  • Text Search & Selection
  • PDF Navigation - outlines, bookmarks

Annotations:

  • Notes - add longer comments with adjustable icon shape and color

  • Ink - freehand drawing with customizable color, opacity, line thickness

  • Text - add, move, resize text directly on page

  • Inspector - adjust annotation looks (line styles, borders, colors, opacity, font)

  • Comment on Annotations and Update Status

  • Import & Export & Flatten Annotations (XFDF, FDF, JSON)

  • Highlight, Underline, Strikeout, Squiggly

  • Shapes - Rectangle, Oval, Line, Arrow, Polygon, Polyline, Cloud

  • Stamps, Sound, Movie, File Attachment, Link, Distance, Perimeter, Area

Forms:

  • Process fillable and static PDF forms

  • Form filling, form creation, form flattening

Document Editor:

  • Page manipulation - insert, delete, rotate, reorder, extract, crop

  • Split PDF, Merge PDF

Content Editor: Edit PDF text and images directly like in Word

Security:

  • Encryption - set open password, permission password

  • Restrict printing, copying, editing

Signatures:

  • Electronic Signatures - draw, type, image signatures

  • Digital Signatures - certificate-based signature validation

Watermark:

  • Add Text or Image Watermarks

  • Delete Watermarks

  • Customize Watermarks

OCR:

  • AI OCR

  • Recognize Tables, Graphics, Images

  • Support recognition in 80+ Languages

Compare Documents: Side-by-side document comparison to highlight differences

Redaction: Permanently remove sensitive content from PDFs

Measurement: Distance, area, perimeter measurement tools

Compress: Optimize and reduce PDF file size

Convert Files:

  • Convert PDF to Word, Excel, PPT, HTML, CSV, images (PNG,JPEG, JPEG, JPEG2000, BMP, TIFF, TGA, GIF), RTF, TXT, JSON, XML, markdown, searchable PDF, searchable OFD.

  • Convert images (PNG,JPEG, JPEG, JPEG2000, BMP, TIFF, TGA, GIF) to Word, Excel, PPT, HTML, CSV, RTF, TXT, JSON, XML.

  • Convert Word, Excel, PPT, HTML, CSV, PNG, RTF, TXT to PDF

UI Customization:

  • Toolbar Customization

  • UI Personalization

  • Ready-Made UI Options

  • Out-of-the-box Source Code

Preview

ComPDF SDK for Android delivers a smooth, feature-rich PDF experience on mobile devices.

ComPDF SDK for Android UI

Requirements

ComPDF SDK for Android supports Android devices running API level 19 or newer and targets the latest stable Android 4.4 or later. In addition, it requires applications to be built with Java 8 language features enabled.

  • Android Studio 3.2 or newer (support AndroidX).
  • Project specifications:
  • A minSdkVersion of 19 or higher.
  • A compileSdkVersion of 30 or higher.
  • A targetSdkVersion of 34 or higher.
  • Android ABI(s): x86, x86_64, armeabi-v7a, arm64-v8a.

How to Make an Android PDF Viewer in Java

This section will help you quickly get started with ComPDF SDK to make an Android app in Java with step-by-step instructions. Through the following steps, you will get a simple application that can display the contents of a specified PDF file.

Video Guide: Build an Android PDF Editor in Java image-youtube-20250615

Create a New Project

  1. Use Android Studio to create a Phone & Tablet project. Here we create a No Activity project.

Create a New Android Project

Installation

Integrate With Gradle

  1. Open the settings.gradle file located in your project's root directory and add the mavenCentral repository:

    dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() + mavenCentral() } }

  2. Open the build.gradle file in the application module directory:

Integrate With Gradle

Edit it and add the complete ComPDF SDK dependency:

dependencies {
  implementation 'com.compdf:compdfkit:2.6.9'
  implementation 'com.compdf:compdfkit-ui:2.6.9'
}
  1. Apply for read and write permissions in AndroidManifest.xml:

Note: On your apps that target Android 6.0 or higher, make sure to check for and request read and write permissions to external storage at runtime.

  1. If you use an online license, please add network access permissions in AndroidManifest.xml:

Integrate Manually

  1. Copy "ComPDFKit.aar" and "ComPDFKit-UI.aar" to the "libs" directory of the app.

Integrate Manually)

  1. Add the following code into the app dictionary's "build.gradle" file:

    ... dependencies { /ComPDF SDK/ implementation(fileTree('libs')) ... } ...

  2. Add ComPDF SDK for Android as a dependency to the project. Inside the app dictionary's "build.gradle", add "ComPDFKit.aar", "ComPDFKit-UI.aar", and the related support libraries to the dependencies. For simplicity, update the dependencies as follows:

    dependencies { ... //glide implementation 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

    implementation 'androidx.documentfile:documentfile:1.0.1'
    

    }

  3. Apply for read and write permissions in AndroidManifest.xml:

Note: On your apps that target Android 6.0 or higher, make sure to check for and request read and write permissions to external storage at runtime.

  1. If you use an online license, please add network access permissions in AndroidManifest.xml:

Apply the License Key

Add this license in the AndroidManifest.xml of the main module. In version 1.13.0, we introduced a brand-new online authentication license scheme for ComPDF SDK. By default, the SDK performs online authentication. If you are using a version prior to 1.13.0, please refer to the following example to configure the SDK for offline authentication mode:

  • Online license

You can also initialize ComPDF SDK in code using:

CPDFSdk.init(context, "your compdfkit license", false);
  • Offline license

You can also initialize ComPDF SDK in code using:

CPDFSdk.init(context, "your compdfkit license");

Add Proguard Rules

In the proguard-rules.pro file, please add the obfuscation configuration information for compdfkit as follows:

-keep class com.compdfkit.ui.** {*;}
-keep class com.compdfkit.core.** {*;}

Display a PDF Document

  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.

Display a PDF Document  1

  1. Create a new Empty Activity under your package, and set the activity name to MainActivity.

Display a PDF Document  2

Android Studio will automatically generate a source file called "MainActivity.java" and a layout file called "activity_main.xml".

The source file:

Display a PDF Document  3

The layout file:

Display a PDF Document  4

  1. Create a CPDFReaderView in your "activity_main.xml" to display the contents of the PDF document:

```xml

<com.compdfkit.ui.reader.CPDFReaderView
    android:id="@+id/readerview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />


Get the `CPDFReaderView` from the layout or create a `CPDFReaderView` directly in the code in the corresponding ***MainActivity.java*** file:
```Java
// Your MainActivity.java file

package com.compdfkit.pdfviewer;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import com.compdfkit.ui.reader.CPDFReaderView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Get CPDFReaderView from xml.
        CPDFReaderView readerView = findViewById(R.id.readerview);
        // Code to create CPDFReaderView.
        // CPDFDocument readerView = new CPDFReaderView(content);
    }
}
  1. Open the document. This is a time-consuming process, so it needs to be executed in a sub-thread. After the document is opened successfully, the UI that renders the PDF is initiated:

```Java // Your MainActivity.java file

... //imports

public class MainActivity extends AppCompatActivity {

// Copy the PDF file from the assets folder to the cache folder.
private void copyPdfFromAssetsToCache(String fileName) {
    try {
        InputStream inputStream = getAssets().open(fileName);
        File outputFile = new File(getCacheDir(), fileName);
        FileOutputStream outputStream = new

Extension points exported contracts — how you extend this code

CPDFSearch (Interface)
Tools module search function interface, including default search function and PDF content editing, search and replacemen [6 …
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/viewer/pdfsearch/data/CPDFSearch.java
OnItemClickListener (Interface)
(no doc) [32 implementers]
samples/src/main/java/com/compdfkit/samples/SampleListAdapter.java
FeaturesSamples (Interface)
(no doc) [52 implementers]
PDFViewer/src/main/java/com/compdfkit/pdfviewer/home/samples/FeaturesSamples.java
OutputListener (Interface)
(no doc) [2 implementers]
Samples_kotlin/src/main/java/com/compdfkit/samples/util/OutputListener.kt
OnClickSearchItemListener (Interface)
(no doc) [32 implementers]
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/viewer/pdfsearch/adapter/CSearchPDFTextRecyclerviewAdapter.java
OutputListener (Interface)
(no doc) [3 implementers]
samples/src/main/java/com/compdfkit/samples/util/OutputListener.java
COnColorChangeListener (Interface)
(no doc) [7 implementers]
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/view/colorpicker/widget/ColorPickerView.java
COnColorAlphaChangeListener (Interface)
(no doc) [7 implementers]
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/view/colorpicker/widget/ColorPickerView.java

Core symbols most depended-on inside this repo

getContext
called by 627
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/basic/fragment/CBasicThemeFragment.java
println
called by 561
samples/src/main/java/com/compdfkit/samples/util/OutputListener.java
getString
called by 265
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/pdfproperties/pdfsign/CDigitalSignStylePreviewView.java
getCPdfReaderView
called by 208
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfview/CPDFViewCtrl.java
setOnClickListener
called by 207
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/adapter/CBaseQuickViewHolder.java
getStyle
called by 184
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/pdfstyle/manager/provider/CStyleProvider.java
getId
called by 173
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/config/bota/CPDFBotaItemMenu.java
dismiss
called by 144
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/interfaces/COnDialogDismissListener.java

Shape

Method 4,090
Class 492
Interface 105
Enum 37

Languages

Java97%
Kotlin3%

Modules by API surface

ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/pdfstyle/CAnnotStyle.java160 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/security/watermark/view/CWatermarkView.java68 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfview/CPDFViewCtrl.java66 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/pdfstyle/manager/CStyleManager.java61 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/contextmenu/CPDFContextMenuHelper.java59 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/basic/CBasicPropertiesFragment.java48 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/annotation/pdfannotationbar/CAnnotationToolbar.java48 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/views/pdfproperties/stamp/CPDFStampTextView.java41 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/pdf/CPDFDocumentFragment.java37 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/viewer/pdfsearch/CSearchReplaceToolbar.java35 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/viewer/pdfinfo/CDocumentInfoBean.java35 symbols
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/docseditor/pdfpageedit/CPDFPageEditDialogFragment.java35 symbols

For agents

$ claude mcp add compdfkit-pdf-sdk-android \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact