Skip to content

Commit

Permalink
Add little fixes
Browse files Browse the repository at this point in the history
Update README and CHANGELOG
Update version
  • Loading branch information
barteksc committed Jul 12, 2016
1 parent 312fbe5 commit c596e99
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.3.1'
libraryVersion = '1.4.0'

developerId = 'barteksc'
developerName = 'Bartosz Schiller'
Expand All @@ -44,7 +44,7 @@ android {
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.3.1"
versionName "1.4.0"
}
buildTypes {
release {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/shockwave/pdfium/PdfiumCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
14 changes: 8 additions & 6 deletions src/main/jni/src/mainJNILib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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<FPDF_PAGE>(pagePtr);

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c596e99

Please sign in to comment.