Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update README.md and CHANGELOG.md
  • Loading branch information
robinshi-mega committed Jan 6, 2025
commit 8d397016e5481b0b26017608ebcd6bcafae967aa
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## 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 `.so` file
* 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
```

## 1.9.0 (2018-06-29)
* Updated Pdfium library to 7.1.2_r36
* Changed `gnustl_static` to `c++_shared`
Expand Down
149 changes: 3 additions & 146 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,149 +1,6 @@
## What's new in 1.9.1?
- 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 `.so` file
- 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
```
# Introduction
This repository is a fork of [barteksc/PdfiumAndroid](https://github.com/meganz/PdfiumAndroid).

On top of the original project, this fork adds the 16KB page size support for Android15. The changes include upgrading to [PDFium 133.0.6927.0](https://github.com/bblanchon/pdfium-binaries/releases/tag/chromium%2F6927) and adding a `CMakeLists.txt` for building `.so` file.


# Pdfium Android binding with Bitmap rendering
Uses pdfium library [from AOSP](https://android.googlesource.com/platform/external/pdfium/)

The demo app (for not modified lib) is [here](https://github.com/mshockwave/PdfiumAndroid-Demo-App)

Forked for use with [AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer) project.

API is highly compatible with original version, only additional methods were created.

## What's new in 1.9.0?
* 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

## Installation
Add to _build.gradle_:

`compile 'com.github.barteksc:pdfium-android:1.9.0'`

Library is available in jcenter and Maven Central repositories.

## Methods inconsistency
Version 1.8.0 added method for getting page size - `PdfiumCore#getPageSize(...)`.
It is important to note, that this method does not require page to be opened. However, there are also
old `PdfiumCore#getPageWidth(...)`, `PdfiumCore#getPageWidthPoint(...)`, `PdfiumCore#getPageHeight()`
and `PdfiumCore#getPageHeightPoint()` which require page to be opened.

This inconsistency will be resolved in next major version, which aims to redesign API.

## Reading links
Version 1.8.0 introduces `PdfiumCore#getPageLinks(PdfDocument, int)` method, which allows to get list
of links from given page. Links are returned as `List` of type `PdfDocument.Link`.
`PdfDocument.Link` holds destination page (may be null), action URI (may be null or empty)
and link bounds in document page coordinates. To map page coordinates to screen coordinates you may use
`PdfiumCore#mapRectToDevice(...)`. See `PdfiumCore#mapPageCoordsToDevice(...)` for parameters description.

Sample usage:
``` java
PdfiumCore core = ...;
PdfDocument document = ...;
int pageIndex = 0;
core.openPage(document, pageIndex);
List<PdfDocument.Link> links = core.getPageLinks(document, pageIndex);
for (PdfDocument.Link link : links) {
RectF mappedRect = core.mapRectToDevice(document, pageIndex, ..., link.getBounds())

if (clickedArea(mappedRect)) {
String uri = link.getUri();
if (link.getDestPageIdx() != null) {
// jump to page
} else if (uri != null && !uri.isEmpty()) {
// open URI using Intent
}
}
}

```

## Simple example
``` java
void openPdf() {
ImageView iv = (ImageView) findViewById(R.id.imageView);
ParcelFileDescriptor fd = ...;
int pageNum = 0;
PdfiumCore pdfiumCore = new PdfiumCore(context);
try {
PdfDocument pdfDocument = pdfiumCore.newDocument(fd);

pdfiumCore.openPage(pdfDocument, pageNum);

int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum);
int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum);

// ARGB_8888 - best quality, high memory usage, higher possibility of OutOfMemoryError
// RGB_565 - little worse quality, twice less memory usage
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.RGB_565);
pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageNum, 0, 0,
width, height);
//if you need to render annotations and form fields, you can use
//the same method above adding 'true' as last param

iv.setImageBitmap(bitmap);

printInfo(pdfiumCore, pdfDocument);

pdfiumCore.closeDocument(pdfDocument); // important!
} catch(IOException ex) {
ex.printStackTrace();
}
}

public void printInfo(PdfiumCore core, PdfDocument doc) {
PdfDocument.Meta meta = core.getDocumentMeta(doc);
Log.e(TAG, "title = " + meta.getTitle());
Log.e(TAG, "author = " + meta.getAuthor());
Log.e(TAG, "subject = " + meta.getSubject());
Log.e(TAG, "keywords = " + meta.getKeywords());
Log.e(TAG, "creator = " + meta.getCreator());
Log.e(TAG, "producer = " + meta.getProducer());
Log.e(TAG, "creationDate = " + meta.getCreationDate());
Log.e(TAG, "modDate = " + meta.getModDate());

printBookmarksTree(core.getTableOfContents(doc), "-");

}

public void printBookmarksTree(List<PdfDocument.Bookmark> tree, String sep) {
for (PdfDocument.Bookmark b : tree) {

Log.e(TAG, String.format("%s %s, p %d", sep, b.getTitle(), b.getPageIdx()));

if (b.hasChildren()) {
printBookmarksTree(b.getChildren(), sep + "-");
}
}
}

```
## Build native part
Go to `PROJECT_PATH/src/main/jni` and run command `$ ndk-build`.
This step may be executed only once, every future `.aar` build will use generated libs.