Skip to content

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

License

Notifications You must be signed in to change notification settings

opendocument-app/pdf2htmlEX-Android

Repository files navigation

pdf2htmlEX library port 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.26")
}

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.