pdf2htmlEX-Android icon indicating copy to clipboard operation
pdf2htmlEX-Android copied to clipboard

pdf2htmlEX library port for Android - Convert PDF to HTML without losing text or format

pdf2htmlEX library port for Android

Made possible by ndkports (a collection of Open Source Linux libraries for Android).

build Maven Central

Used by:

C++ runtime dependency:

Using prebuilt libraries is less problematic if all the libraries used in the application are:

  • Built with the same major version of toolchain - ndk-26
  • Linked against shared C++ STL - android.defaultConfig.externalNativeBuild.cmake.arguments "-DANDROID_STL=c++_shared" in app's (and all JNI dependencies) build.gradle.

How to install:

pdf2htmlEX-Android is distributed through MavenCentral. Add a dependency in build.gradle:

dependencies {
    implementation("app.opendocument:pdf2htmlex-android:0.18.24")
}

Usage:

Library is interfaced through Java.

import app.opendocument.android.pdf2htmlex.pdf2htmlEX;
...
java.io.File inputPdf = new java.io.File(getFilesDir(), "my.pdf");
java.io.File outputHTML = new pdf2htmlEX(getApplicationContext()).setInputPDF(inputPdf).convert();

Encrypted PDF documents need a password to be decrypted.

Either owner (admin):

java.io.File outputHTML = new pdf2htmlEX(getApplicationContext()).setInputPDF(inputPdf).setOwnerPassword("owner-password").convert();

or user password can be used:


java.io.File outputHTML = new pdf2htmlEX(getApplicationContext()).setInputPDF(inputPdf).setUserPassword("user-password").convert();

Library needs Android Context to obtain path to cache directory and asset files, which are supplied in .aar.