Skip to content

PdfiumAndroid with Supporting Android API >=21 #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ src/main/obj
/local.properties
.idea/
.DS_Store
.cxx
/build
/captures
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 1.9.4 (2024-03-19)
* Fix issue for the newest Android devices with API 34+

## 1.9.3 (2024-03-18)
* Update Gradle plugins and configurations
* Change minimum SDK to 21
* Update pdfium libs

## 1.9.1 (2024-03-10)
* Update Gradle plugins and configurations
* Update compile sdk to 34
* Change minimum SDK to 23
* Remove support-v4 library
* Drop support for mips
* Update pdfium libs and refactor to cmake

## 1.9.0 (2018-06-29)
* Updated Pdfium library to 7.1.2_r36
* Changed `gnustl_static` to `c++_shared`
Expand Down
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# Pdfium Android binding with Bitmap rendering
Uses pdfium library [from AOSP](https://android.googlesource.com/platform/external/pdfium/)
The purpose is to remove old support libraries so we no longer need to use jetifier.

The demo app (for not modified lib) is [here](https://github.com/mshockwave/PdfiumAndroid-Demo-App)
It will be used with the forked [AndroidPdFViewer](https://github.com/lion1988dev/AndroidPdfViewer)

Forked for use with [AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer) project.
## What's new in 1.9.4
* Fix issue for the newest Android devices with API 34+

API is highly compatible with original version, only additional methods were created.
## What's new in 1.9.3
* Update Gradle plugins and configurations
* Change minimum SDK to 21
* Update pdfium libs

## What's new in 1.9.1
* Update Gradle plugins and configurations
* Update compile sdk to 34
* Change minimum SDK to 23
* Remove support-v4 library
* Drop support for mips
* Update pdfium libs and refactor to cmake

## What's new in 1.9.0?
* Updated Pdfium library to 7.1.2_r36
Expand All @@ -16,9 +27,21 @@ API is highly compatible with original version, only additional methods were cre
* Add support for mips64

## Installation
Add to _build.gradle_:
Add to the root _build.gradle_:

```groovy
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
```

Add to the app _build.gradle_:

`compile 'com.github.barteksc:pdfium-android:1.9.0'`
`implementation 'com.github.lion1988dev:PdfiumAndroid:1.9.4'`

Library is available in jcenter and Maven Central repositories.

Expand Down
117 changes: 69 additions & 48 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,75 +1,96 @@
buildscript {
repositories {
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
plugins {
id 'com.android.library' version '8.3.0'
id 'maven-publish'
}

apply plugin: 'com.android.library'

ext {
bintrayRepo = 'maven'
bintrayName = 'pdfium-android'
tools = [
minSdk : 21,
targetSdk : 34,
compileSdk : 34,
versionCode: 3,
versionName: '1.9.4'
]
}

publishedGroupId = 'com.github.barteksc'
libraryName = 'PdfiumAndroid'
artifact = 'pdfium-android'
group "com.github.lion1988dev"

libraryDescription = 'Fork of library for rendering PDFs on Android\'s Surface or Bitmap'
android {
namespace "com.shockwave.pdfium"

siteUrl = 'https://github.com/barteksc/PdfiumAndroid'
gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git'
compileSdk rootProject.tools.compileSdk

libraryVersion = '1.9.0'
defaultConfig {
minSdkVersion rootProject.tools.minSdkVersion
targetSdk rootProject.tools.targetSdk

developerId = 'barteksc'
developerName = 'Bartosz Schiller'
developerEmail = 'barteksch@boo.pl'
versionCode rootProject.tools.versionCode
versionName "${rootProject.tools.versionName}"

licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
buildConfigField 'String', 'VERSION_NAME', "\"${defaultConfig.versionName}\""

android {
compileSdkVersion 26
externalNativeBuild {
cmake {
cppFlags ""
}
}
}

defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.9.0"
buildFeatures {
buildConfig = true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

sourceSets{
main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

publishing {
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

ndkVersion '25.2.9519653'

externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.22.1"
}
}
}

repositories {
google()
jcenter()
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:26.1.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
publishing {
publications {
release(MavenPublication) {
groupId = 'com.github.lion1988dev'
artifactId = 'PdfiumAndroid'
version = "1.9.4"

afterEvaluate {
from components.release
}
}
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.enableJetifier=false
android.useAndroidX=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 06 19:49:00 CEST 2017
#Sat Mar 09 21:57:57 EET 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
17 changes: 17 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}

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

rootProject.name = "PdfiumAndroid"
13 changes: 0 additions & 13 deletions src/androidTest/java/com/shockwave/pdfium/ApplicationTest.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.shockwave.pdfium">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
72 changes: 72 additions & 0 deletions src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.22.1)

# Declares and names the project.

project("pdfiumandroid")

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
pdfiumandroid

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
mainJNILib.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
log-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
log)

find_library( # Sets the name of the path variable.
android-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
android)

find_library( # Sets the name of the path variable.
jnigraphics-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
jnigraphics)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
pdfiumandroid

libpdfium

# Links the target library to the log library
# included in the NDK.
${log-lib}
${android-lib}
${jnigraphics-lib}
)


add_library( libpdfium SHARED IMPORTED )

set_target_properties( libpdfium PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libpdfium.cr.so)
Loading