From 063a723b9fa50200192b01ba976ecd551461a8dc Mon Sep 17 00:00:00 2001 From: Matt Holgate Date: Fri, 27 Jun 2014 12:30:39 +0100 Subject: Fix #695217 - don't allow annotation of encrypted PDFs --- platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java | 2 +- platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'platform/android/src/com') 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(); } -- cgit v1.2.3