Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9a47e5d
Add native and java methods for rendering on bitmap and reading page …
barteksc May 22, 2016
45a1d45
Updated README
barteksc May 28, 2016
9f5f026
Fix loading library for older Android versions
barteksc May 29, 2016
d5ce6ce
Add exception throwing on error to PdfCore.newDocument
barteksc Jun 4, 2016
1ebe3b8
Update README
barteksc Jun 4, 2016
d4c24a5
Fixed bug when pdf should open as normal but was throwing exception
barteksc Jun 16, 2016
3995d83
Compiled pdfium with SONAME set to libmodpdfium
barteksc Jun 27, 2016
ea97a4b
Add libmodpdfium recompiled with metadata and bookmarks support
barteksc Jul 6, 2016
7ff43ba
Add opening documents with password
barteksc Jul 10, 2016
d26fc8c
Adding support for rendering annotations
yusefmaali Jul 11, 2016
918146e
Help with recognition of password requirement or incorrect password.
barteksc Jul 11, 2016
4bcf723
Merge branch 'master' of https://github.com/usef/PdfiumAndroid into u…
barteksc Jul 12, 2016
312fbe5
Merge branch 'usef-master'
barteksc Jul 12, 2016
c596e99
Add little fixes
barteksc Jul 12, 2016
641b77c
Add method `PdfiumCore#newDocument(byte[])` for reading PDF documents…
barteksc Nov 18, 2016
988cf09
Update pdfium to version from Android 7.1.1
barteksc Mar 22, 2017
dc35694
Let the world know about the renderAnnot param
matpag Jun 2, 2017
bab91ca
Merge pull request #21 from matpag/render-annot-readme
Jun 2, 2017
c873b24
Fix rendering not embedded fonts
barteksc Jun 9, 2017
988f5cb
Add rendering bitmap in RGB 565 format
barteksc Jun 21, 2017
6b74ac7
Added try to native library loading
Phaestion Oct 24, 2017
84ab046
Merge branch 'Phaestion-native_lib_crashing_app'
barteksc Oct 27, 2017
2264274
Remove unused resources file
barteksc Oct 27, 2017
f396da4
Update README and CHANGELOG
barteksc Oct 28, 2017
1388325
Add support for links
barteksc Nov 11, 2017
6000c42
Handle PdfiumCore#getPageSize() errors
barteksc Nov 15, 2017
af0202b
fixed potential NPE
Nov 27, 2017
38d70ad
Merge branch 'mcsong-master'
barteksc Dec 15, 2017
981f4cc
Merge pull request fixing potential NPE when getting links
barteksc Dec 15, 2017
bf97ffb
Use pdfium built with c++_shared
barteksc Jun 28, 2018
103d585
Update CHANGELOG
barteksc Jun 28, 2018
cd0b59a
AND-20185 Upgrade with latest Pdfium
robinshi-mega Jan 6, 2025
e982d34
Merge branch 'rsh/AND-20185-upgrade-with-latest-PdfiumCore' into 'mas…
robinshi-mega Jan 6, 2025
a3abf34
Update README.md
robinshi-mega Jan 6, 2025
8d39701
Update README.md and CHANGELOG.md
robinshi-mega Jan 6, 2025
7cd3803
AND-20185 rebuild libpng and libfreetype2
robinshi-mega Jan 6, 2025
9fe3406
Merge branch 'rsh/AND-20185-rebuild-libpng-and-libfreetype' into 'mas…
robinshi-mega Jan 6, 2025
000c3ba
AND-20185 Update documentations
robinshi-mega Jan 6, 2025
0ce30e7
AND-20185 Create build script to build Pdfium and deploy to MEGA code
robinshi-mega Jan 9, 2025
5eb45ef
AND-20450 Upgrade freetype2 library
robinshi-mega Mar 14, 2025
d4e92cc
Update PdfiumAndroid for SDK 35/NDK 28/Android 15 compatibility
visyan Jul 30, 2025
e78b5da
Update to version 2.0.0 with versioned AAR filename
visyan Jul 30, 2025
8c60bb4
version 2.0.1 -> API36
Aiuspaktyn Aug 1, 2025
40003b2
version 2.0.2 -> 16KB page size support
Aiuspaktyn Sep 27, 2025
76b875c
Update README.md
Aiuspaktyn Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/build

src/main/libs
src/main/obj

*.iml
*.iml
.gradle
/local.properties
.idea/
.DS_Store
/build
/captures


# build directories
builddir/*
freetype-*
libpng
111 changes: 111 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
## 2.0.2 (2025-09-27)
* Android 16 (16KB page size support)

## 1.9.2 (2025-03-15)
* Upgrade libfreetype to 2.13.3
* It is a security update, see [here](https://nvd.nist.gov/vuln/detail/CVE-2025-27363) for more details.

## 1.9.1 (2025-01-06)
* Upgrade to latest [PDFium 133.0.6927.0](https://github.com/bblanchon/pdfium-binaries/releases/tag/chromium%2F6927)
* Upgrade `include` folder
* Upgrade `libmodpdfium.so` for `arm32`, `arm64`, `x86` and `x86_64`(`mips` binary not included)
* Use new Pdfium API in `mainJNILib.cpp`
* Add `CMakeLists.txt` for building the PdfiumAndroid library
* Example cmake command
```bash
export ABI=arm64-v8a && \
export NDK_ROOT=PATH/TO/NDK && \
cmake -B builddir/${ANDROID_ABI}/ \
-S . \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_NDK=${NDK_ROOT} \
-DCMAKE_ANDROID_NDK=${NDK_ROOT} \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_ANDROID_ARCH_ABI=${ANDROID_ABI} \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_PLATFORM=android-26 \
-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON
```
* Add [libpng v1.6.44](https://github.com/pnggroup/libpng/releases/tag/v1.6.44) and [libfreetype2 v2.10.0](https://download.savannah.gnu.org/releases/freetype/) binaries for building PdfiumAndroid library.
* Add `build.sh` script for building `libpng` and `libfreetype2`

## 1.9.0 (2018-06-29)
* Updated Pdfium library to 7.1.2_r36
* Changed `gnustl_static` to `c++_shared`
* Update Gradle plugins
* Update compile SDK and support library to 26
* Change minimum SDK to 14
* Add support for mips64

## 1.8.2 (2017-12-15)
* Merge pull request by [mcsong](https://github.com/mcsong) fixing potential NPE when getting links

## 1.8.1 (2017-11-15)
* Handle `PdfiumCore#getPageSize()` errors and return `Size(0, 0)`

## 1.8.0 (2017-11-11)
* Add method for reading links from given page
* Add method for mapping page coordinates to screen coordinates
* Add `PdfiumCore#getPageSize(...)` method, which does not require page to be opened
* Add `Size` and `SizeF` utility classes
* Add javadoc comments to `PdfiumCore`

## 1.7.1 (2017-10-28)
* Merge pull request by [Phaestion](https://github.com/Phaestion) which prevents `UnsatisfiedLinkError`

## 1.7.0 (2017-06-21)
* Add rendering bitmap in RGB 565 format, which reduces memory usage (about twice)

## 1.6.1 (2017-06-09)
* Fix bug from 1.6.0 - not embedded fonts was not rendered

## 1.6.0 (2017-03-22)
* Pdfium updated to newest version, from Android 7.1.1.
It should fix many rendering issues and (thanks to freetype support) fix problems with fonts.

## 1.5.0 (2016-11-18)
* Add method `PdfiumCore#newDocument(byte[])` for reading PDF documents from memory
* Cleanup AndroidManifest.xml to solve problems with manifest merger

## 1.4.0 (2016-07-12)
* merge pull request by [usef](https://github.com/usef) with added support for rendering annotations. Due to limitations of _Pdfium_, messages from comments cannot be read and are rendered only as speech balloons.

## 1.3.1 (2016-07-11)
* `PdfiumCore#newDocument()` may throw `PdfPasswordException` to help with recognition of password requirement or incorrect password.

## 1.3.0 (2016-07-10)
* added support for opening documents with password
* fixed bug with SIGSEV when closing document

## 1.2.0 (2016-07-06)
* `libmodpdfium` compiled with methods for retrieving bookmarks and metadata
* added `PdfiumCore#getDocumentMeta()` for retrieving document metadata
* added `PdfiumCore#getTableOfContents()` for reading whole tree of bookmarks
* comment out native rendering debug

## 1.1.0 (2016-06-27)
* fixed rendering multiple PDFs at the same time thanks to synchronization between instances
* compile Pdfium with SONAME `libmodpdfium` to prevent loading `libpdfium` from Lollipop and higher
* `newDocument()` requires `ParcelFileDescriptor` instead of `FileDescriptor` to keep file descriptor open
* changed method of loading PDFs, which should be more stable

## 1.0.3 (2016-06-17)
* probably fixed bug when pdf should open as normal but was throwing exception
* added much more descriptive exception messages

## 1.0.2 (2016-06-04)
* `newDocument()` throws IOException

## 1.0.1 (2016-06-04)
* fix loading `libpdfium` on devices with < Lollipop

## Initial changes
* Added method for rendering PDF page on bitmap

``` java
void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex,
int startX, int startY, int drawSizeX, int drawSizeY);
```
* Added methods to get width and height of page in points (1/72") (like in `PdfRenderer.Page` class):
* `int getPageWidthPoint(PdfDocument doc, int index);`
* `int getPageHeightPoint(PdfDocument doc, int index);`
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Set the minimum required version of CMake
cmake_minimum_required(VERSION 3.22)

# Set the project name and language
project(jniPdfium LANGUAGES CXX)

message(STATUS "ANDROID_NDK: ${ANDROID_NDK}")
message(STATUS "CMAKE_ANDROID_NDK: ${CMAKE_ANDROID_NDK}")
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_ANDROID_ARCH_ABI: ${CMAKE_ANDROID_ARCH_ABI}")
message(STATUS "ANDROID_ABI: ${ANDROID_ABI}")
message(STATUS "ANDROID_PLATFORM: ${ANDROID_PLATFORM}")


# Add the source files for the library
set(SOURCES
src/main/jni/src/mainJNILib.cpp
src/main/jni/src/util.hpp
)

# Create the shared library target
add_library(jniPdfium SHARED ${SOURCES})

# Specify include directories if necessary
target_include_directories(jniPdfium
PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/include
)

# Specify the dependent dynamic libraries to link against
target_link_libraries(jniPdfium
PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libmodft2.so
PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libmodpdfium.so
PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libmodpng.so
PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libc++_shared.so
)

# Specify additional compile options if required
target_compile_options(jniPdfium PRIVATE
-Wall -Wextra -DHAVE_PTHREADS
)

# Specify additional linker flags if necessary
target_link_options(jniPdfium PRIVATE
-Wl,--no-undefined -llog -landroid -ljnigraphics
)
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright 2015 Bekket McClane
Original work Copyright 2015 Bekket McClane
Modified work Copyright 2016 Bartosz Schiller

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
128 changes: 123 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,123 @@
#Pdfium Android( >= API Level 9 ) binding
Use pdfium library [from AOSP](https://android.googlesource.com/platform/external/pdfium/)<br>
The demo app is [here](https://github.com/mshockwave/PdfiumAndroid-Demo-App)
<h2>TODO:</h2><br>
* Push to Maven Central
# PdfiumAndroid - SDK 36 / Android 16 Compatible

This repository is a fork of [meganz/PdfiumAndroid](https://github.com/meganz/PdfiumAndroid), which itself is based on [barteksc/PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid).

## What's New in This Fork

This fork is updated to **SDK 35 / NDK 28** and delivers a working AAR compatible with **Android 15 (16KB page size support)**.

**Version 2.0.2** - Significant updates to the build layer and compatibility improvements warrant a major version bump from the original 1.9.0.

### Key Updates:
- **Android SDK 36** and **NDK 28** compatibility
- **Android Gradle Plugin 8.13.0** support
- **Java 17** requirement (configured via `gradle.properties`)
- **BuildConfig generation** fixed for library modules
- **Native library packaging** corrected in AAR
- **16KB page size support** for Android 15
- **Windows Git Bash** compatible build script

## Requirements

- **Java 17+** (required for AGP 8.13.0+)
- **Android NDK 28.2.13676358**
- **Git Bash** (for Windows users)
- **Ninja build tool** - https://github.com/ninja-build/ninja/releases

## Building the Library

### 1. Build Native Libraries

Remark: you might need to update the `NDK_ROOT` environment variable in the `build.sh` script to point to your NDK (preferrably v28+)

```bash
# Run the build script to compile native libraries
./build.sh

# Optional: Build specific components
./build.sh --build-png --build-freetype

```

### 2. Build AAR

Remark: you might need to update the 'javaHome' environment variable in the `gradle.properties` file to point to your Java 17 installation

```bash
# Build debug AAR
./gradlew assembleDebug

# Build release AAR
./gradlew assembleRelease

# Output: build/outputs/aar/PdfiumAndroid-2.0.0-release.aar
```

## Using in Your Project

### Method 1: Local AAR
1. Copy `PdfiumAndroid-2.0.2-release.aar` to your app's `libs/` folder
2. Add to your app's `build.gradle`:
```groovy
dependencies {
implementation files('libs/PdfiumAndroid-2.0.2-release.aar')
implementation 'androidx.core:core:1.16.0'
}
```

### Method 2: JitPack (if published)
```groovy
repositories {
maven { url 'https://jitpack.io' }
}

dependencies {
implementation 'com.github.aiuspaktyn:PdfiumAndroid:2.0.2'
}
```

## Usage Example

```java
import com.shockwave.pdfium.PdfiumCore;
import com.shockwave.pdfium.PdfDocument;

// Initialize
PdfiumCore pdfiumCore = new PdfiumCore(context);

// Open PDF
PdfDocument pdfDocument = pdfiumCore.newDocument(parcelFileDescriptor);

// Use the library...
```

## Changes Made

### Build System Updates
- Updated `build.gradle` for AGP 8.13.0 compatibility
- Added `buildFeatures { buildConfig = true }`
- Added `buildConfigField` for `VERSION_NAME`
- Fixed `jniLibs.srcDir` path for native libraries
- Configured Java 17 in `gradle.properties`

### Native Library Fixes
- Updated `build.sh` to use ninja (for windows)
- Updated `build.sh` to copy `libjniPdfium.so` to correct location
- Fixed AAR packaging to include all required `.so` files
- Ensured compatibility with NDK 28

### Android 15 Compatibility
- Added 16KB page size support via `ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON`
- Updated manifest and build configuration

## Original Credits

- Original work: [barteksc/PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid)
- 16KB page size foundation: [meganz/PdfiumAndroid](https://github.com/meganz/PdfiumAndroid)
- Upgrade to [PDFium 133.0.6927.0](https://github.com/bblanchon/pdfium-binaries/releases/tag/chromium%2F6927)
- Add a `CMakeLists.txt` for building PdfiumAndroid `.so` file.
- Update [libpng v1.6.44](https://github.com/pnggroup/libpng/releases/tag/v1.6.44) and [libfreetype2 v2.10.0](https://download.savannah.gnu.org/releases/freetype/) binaries for building PdfiumAndroid library.

## License

Same as original project - check the LICENSE file.
Loading