Add FPDF_GetSecurityHandlerRevision
Security handler revision number is needed to interpret file permission.
BUG=None
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/589813002
diff --git a/fpdfsdk/include/fpdfview.h b/fpdfsdk/include/fpdfview.h
index 1b7ae2e..4dcdcf6 100644
--- a/fpdfsdk/include/fpdfview.h
+++ b/fpdfsdk/include/fpdfview.h
@@ -260,6 +260,16 @@
//
DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document);
+// Function: FPDF_GetSecurityHandlerRevision
+// Get the revision for security handler.
+// Parameters:
+// document - Handle to document. Returned by FPDF_LoadDocument function.
+// Return value:
+// The security handler revision number. Please refer to PDF Reference for
+// detailed description. If the document is not protected, -1 will be returned.
+//
+DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
+
// Function: FPDF_GetPageCount
// Get total number of pages in a document.
// Parameters:
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 70494e0..49dabe3 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -340,6 +340,17 @@
return pDict->GetInteger("P");
}
+DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document)
+{
+ if (document == NULL) return -1;
+ CPDF_Document*pDoc = (CPDF_Document*)document;
+ CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser();
+ CPDF_Dictionary* pDict = pParser->GetEncryptDict();
+ if (pDict == NULL) return -1;
+
+ return pDict->GetInteger("R");
+}
+
DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document)
{
if (document == NULL) return 0;