Skip to content

Commit

Permalink
Handle PdfiumCore#getPageSize() errors
Browse files Browse the repository at this point in the history
Update README and CHANGELOG
Update version
  • Loading branch information
barteksc committed Nov 15, 2017
1 parent 1388325 commit 6000c42
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ API is highly compatible with original version, only additional methods were cre
* Add `Size` and `SizeF` utility classes
* Add javadoc comments to `PdfiumCore`

1.8.1 handles errors when using `PdfiumCore#getPageSize(PdfDocument, int)` and returns `Size(0, 0)` when error occurs

## Installation
Add to _build.gradle_:

`compile 'com.github.barteksc:pdfium-android:1.8.0'`
`compile 'com.github.barteksc:pdfium-android:1.8.1'`

Library is available in jcenter and Maven Central repositories.

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ext {
siteUrl = 'https://github.com/barteksc/PdfiumAndroid'
gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git'

libraryVersion = '1.8.0'
libraryVersion = '1.8.1'

developerId = 'barteksc'
developerName = 'Bartosz Schiller'
Expand All @@ -44,7 +44,7 @@ android {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.8.0"
versionName "1.8.1"
}
buildTypes {
release {
Expand Down
7 changes: 6 additions & 1 deletion src/main/jni/src/mainJNILib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ JNI_FUNC(jobject, PdfiumCore, nativeGetPageSizeByIndex)(JNI_ARGS, jlong docPtr,
}

double width, height;
FPDF_GetPageSizeByIndex(doc->pdfDocument, pageIndex, &width, &height);
int result = FPDF_GetPageSizeByIndex(doc->pdfDocument, pageIndex, &width, &height);

if (result == 0) {
width = 0;
height = 0;
}

jint widthInt = (jint) (width * dpi / 72);
jint heightInt = (jint) (height * dpi / 72);
Expand Down

0 comments on commit 6000c42

Please sign in to comment.