From c596e999ecf9c8dbf1a08c045243334288b4d0fe Mon Sep 17 00:00:00 2001 From: Bartosz Schiller Date: Tue, 12 Jul 2016 21:33:21 +0200 Subject: [PATCH] Add little fixes Update README and CHANGELOG Update version --- CHANGELOG.md | 3 +++ README.md | 9 +++------ build.gradle | 4 ++-- src/main/java/com/shockwave/pdfium/PdfiumCore.java | 12 ++++++------ src/main/jni/src/mainJNILib.cpp | 14 ++++++++------ 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9554807..81efd91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.4.0 (2016-07-12) +* merge pull request by [usef](https://github.com/usef) with added support for rendering annotations. Due to limitations of _Pdfium_, messages from comments cannot be read and are rendered only as speech balloons. + ## 1.3.1 (2016-07-11) * `PdfiumCore#newDocument()` may throw `PdfPasswordException` to help with recognition of password requirement or incorrect password. diff --git a/README.md b/README.md index bdf2c3b..5fa4436 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,13 @@ Forked for use with [AndroidPdfViewer](https://github.com/barteksc/AndroidPdfVie API is highly compatible with original version, only additional methods were created. -## What's new in 1.3.0? -* added support for opening documents with password -* fixed bug with SIGSEV when closing document - -In 1.3.1 `PdfiumCore#newDocument()` may throw `PdfPasswordException` to help with recognition of password requirement or incorrect password. +## What's new in 1.4.0? +* merge pull request by [usef](https://github.com/usef) with added support for rendering annotations. Due to limitations of _Pdfium_, messages from comments cannot be read and are rendered only as speech balloons. ## Installation Add to _build.gradle_: -`compile 'com.github.barteksc:pdfium-android:1.3.1'` +`compile 'com.github.barteksc:pdfium-android:1.4.0'` Library is available in jcenter and Maven Central repositories. diff --git a/build.gradle b/build.gradle index cc615f4..d513512 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { siteUrl = 'https://github.com/barteksc/PdfiumAndroid' gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git' - libraryVersion = '1.3.1' + libraryVersion = '1.4.0' developerId = 'barteksc' developerName = 'Bartosz Schiller' @@ -44,7 +44,7 @@ android { minSdkVersion 9 targetSdkVersion 21 versionCode 1 - versionName "1.3.1" + versionName "1.4.0" } buildTypes { release { diff --git a/src/main/java/com/shockwave/pdfium/PdfiumCore.java b/src/main/java/com/shockwave/pdfium/PdfiumCore.java index c600584..5f5f66c 100644 --- a/src/main/java/com/shockwave/pdfium/PdfiumCore.java +++ b/src/main/java/com/shockwave/pdfium/PdfiumCore.java @@ -47,12 +47,12 @@ public class PdfiumCore { private native void nativeRenderPage(long pagePtr, Surface surface, int dpi, int startX, int startY, int drawSizeHor, int drawSizeVer, - boolean drawAnnot); + boolean renderAnnot); private native void nativeRenderPageBitmap(long pagePtr, Bitmap bitmap, int dpi, int startX, int startY, int drawSizeHor, int drawSizeVer, - boolean drawAnnot); + boolean renderAnnot); private native String nativeGetDocumentMetaText(long docPtr, String tag); @@ -187,12 +187,12 @@ public void renderPage(PdfDocument doc, Surface surface, int pageIndex, public void renderPage(PdfDocument doc, Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, - boolean drawAnnot) { + boolean renderAnnot) { synchronized (lock) { try { //nativeRenderPage(doc.mNativePagesPtr.get(pageIndex), surface, mCurrentDpi); nativeRenderPage(doc.mNativePagesPtr.get(pageIndex), surface, mCurrentDpi, - startX, startY, drawSizeX, drawSizeY, drawAnnot); + startX, startY, drawSizeX, drawSizeY, renderAnnot); } catch (NullPointerException e) { Log.e(TAG, "mContext may be null"); e.printStackTrace(); @@ -210,11 +210,11 @@ public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, - boolean drawAnnot) { + boolean renderAnnot) { synchronized (lock) { try { nativeRenderPageBitmap(doc.mNativePagesPtr.get(pageIndex), bitmap, mCurrentDpi, - startX, startY, drawSizeX, drawSizeY, drawAnnot); + startX, startY, drawSizeX, drawSizeY, renderAnnot); } catch (NullPointerException e) { Log.e(TAG, "mContext may be null"); e.printStackTrace(); diff --git a/src/main/jni/src/mainJNILib.cpp b/src/main/jni/src/mainJNILib.cpp index 27d2a1d..fb01847 100644 --- a/src/main/jni/src/mainJNILib.cpp +++ b/src/main/jni/src/mainJNILib.cpp @@ -284,7 +284,7 @@ static void renderPageInternal( FPDF_PAGE page, int startX, int startY, int canvasHorSize, int canvasVerSize, int drawSizeHor, int drawSizeVer, - bool drawAnnot){ + bool renderAnnot){ FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx( canvasHorSize, canvasVerSize, FPDFBitmap_BGRA, @@ -308,8 +308,9 @@ static void renderPageInternal( FPDF_PAGE page, int baseY = (startY < 0)? 0 : startY; int flags = FPDF_REVERSE_BYTE_ORDER; - if(drawAnnot) + if(renderAnnot) { flags |= FPDF_ANNOT; + } FPDFBitmap_FillRect( pdfBitmap, baseX, baseY, baseHorSize, baseVerSize, 255, 255, 255, 255); //White @@ -323,7 +324,7 @@ static void renderPageInternal( FPDF_PAGE page, JNI_FUNC(void, PdfiumCore, nativeRenderPage)(JNI_ARGS, jlong pagePtr, jobject objSurface, jint dpi, jint startX, jint startY, jint drawSizeHor, jint drawSizeVer, - jboolean drawAnnot){ + jboolean renderAnnot){ ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, objSurface); if(nativeWindow == NULL){ LOGE("native window pointer null"); @@ -355,7 +356,7 @@ JNI_FUNC(void, PdfiumCore, nativeRenderPage)(JNI_ARGS, jlong pagePtr, jobject ob (int)startX, (int)startY, buffer.width, buffer.height, (int)drawSizeHor, (int)drawSizeVer, - (bool)drawAnnot); + (bool)renderAnnot); ANativeWindow_unlockAndPost(nativeWindow); ANativeWindow_release(nativeWindow); @@ -364,7 +365,7 @@ JNI_FUNC(void, PdfiumCore, nativeRenderPage)(JNI_ARGS, jlong pagePtr, jobject ob JNI_FUNC(void, PdfiumCore, nativeRenderPageBitmap)(JNI_ARGS, jlong pagePtr, jobject bitmap, jint dpi, jint startX, jint startY, jint drawSizeHor, jint drawSizeVer, - jboolean drawAnnot){ + jboolean renderAnnot){ FPDF_PAGE page = reinterpret_cast(pagePtr); @@ -416,8 +417,9 @@ JNI_FUNC(void, PdfiumCore, nativeRenderPageBitmap)(JNI_ARGS, jlong pagePtr, jobj int baseY = (startY < 0)? 0 : (int)startY; int flags = FPDF_REVERSE_BYTE_ORDER; - if(drawAnnot) + if(renderAnnot) { flags |= FPDF_ANNOT; + } FPDFBitmap_FillRect( pdfBitmap, baseX, baseY, baseHorSize, baseVerSize, 255, 255, 255, 255); //White