diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/jni/mupdf.c | 16 | ||||
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java | 2 | ||||
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java | 9 |
3 files changed, 26 insertions, 1 deletions
diff --git a/platform/android/jni/mupdf.c b/platform/android/jni/mupdf.c index 927fef3c..04f1ceff 100644 --- a/platform/android/jni/mupdf.c +++ b/platform/android/jni/mupdf.c @@ -514,6 +514,22 @@ JNI_FN(MuPDFCore_fileFormatInternal)(JNIEnv * env, jobject thiz) return (*env)->NewStringUTF(env, info); } +JNIEXPORT jboolean JNICALL +JNI_FN(MuPDFCore_isUnencryptedPDFInternal)(JNIEnv * env, jobject thiz) +{ + globals *glo = get_globals_any_thread(env, thiz); + if (glo == NULL) + return JNI_FALSE; + + pdf_document *idoc = pdf_specifics(glo->doc); + if (idoc == NULL) + return JNI_FALSE; // Not a PDF + + int cryptVer = pdf_crypt_version(idoc); + return (cryptVer == 0) ? JNI_TRUE : JNI_FALSE; +} + + JNIEXPORT void JNICALL JNI_FN(MuPDFCore_gotoPageInternal)(JNIEnv *env, jobject thiz, int page) { diff --git a/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java index 066b6d5f..6bb45a93 100644 --- a/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java +++ b/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java @@ -483,7 +483,7 @@ public class MuPDFActivity extends Activity implements FilePicker.FilePickerSupp } }); - if (core.fileFormat().startsWith("PDF")) + if (core.fileFormat().startsWith("PDF") && core.isUnencryptedPDF()) { mAnnotButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { diff --git a/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java index ec35ef7c..68aed29e 100644 --- a/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java +++ b/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java @@ -21,11 +21,13 @@ public class MuPDFCore private long globals; private byte fileBuffer[]; private String file_format; + private boolean isUnencryptedPDF; /* The native functions */ private native long openFile(String filename); private native long openBuffer(); private native String fileFormatInternal(); + private native boolean isUnencryptedPDFInternal(); private native int countPagesInternal(); private native void gotoPageInternal(int localActionPageNum); private native float getPageWidth(); @@ -109,6 +111,7 @@ public class MuPDFCore throw new Exception(String.format(context.getString(R.string.cannot_open_file_Path), filename)); } file_format = fileFormatInternal(); + isUnencryptedPDF = isUnencryptedPDFInternal(); } public MuPDFCore(Context context, byte buffer[]) throws Exception @@ -120,6 +123,7 @@ public class MuPDFCore throw new Exception(context.getString(R.string.cannot_open_buffer)); } file_format = fileFormatInternal(); + isUnencryptedPDF = isUnencryptedPDFInternal(); } public int countPages() @@ -135,6 +139,11 @@ public class MuPDFCore return file_format; } + public boolean isUnencryptedPDF() + { + return isUnencryptedPDF; + } + private synchronized int countPagesSynchronized() { return countPagesInternal(); } |