summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-crypt.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-02-12 13:29:37 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-02-12 15:27:58 +0100
commitf597f8dc0552b8e8facd59b11ac64f87fe6736db (patch)
tree7ff4b811ff28adaebace7222a91b7faf77f0f7cf /source/pdf/pdf-crypt.c
parente09f69509f160a22c9290fac054b790b0a80a0cc (diff)
downloadmupdf-f597f8dc0552b8e8facd59b11ac64f87fe6736db.tar.xz
Expose detailed PDF permissions.
Diffstat (limited to 'source/pdf/pdf-crypt.c')
-rw-r--r--source/pdf/pdf-crypt.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c
index f73617ff..a62b12f0 100644
--- a/source/pdf/pdf-crypt.c
+++ b/source/pdf/pdf-crypt.c
@@ -12,19 +12,6 @@ enum
PDF_CRYPT_UNKNOWN,
};
-enum
-{
- PDF_PERM_PRINT = 1 << 2,
- PDF_PERM_CHANGE = 1 << 3,
- PDF_PERM_COPY = 1 << 4,
- PDF_PERM_NOTES = 1 << 5,
- PDF_PERM_FILL_FORM = 1 << 8,
- PDF_PERM_ACCESSIBILITY = 1 << 9,
- PDF_PERM_ASSEMBLE = 1 << 10,
- PDF_PERM_HIGH_RES_PRINT = 1 << 11,
- PDF_DEFAULT_PERM_FLAGS = 0xfffc
-};
-
typedef struct pdf_crypt_filter_s pdf_crypt_filter;
struct pdf_crypt_filter_s
@@ -816,12 +803,20 @@ pdf_has_permission(fz_context *ctx, pdf_document *doc, fz_permission p)
{
case FZ_PERMISSION_PRINT: return doc->crypt->p & PDF_PERM_PRINT;
case FZ_PERMISSION_COPY: return doc->crypt->p & PDF_PERM_COPY;
- case FZ_PERMISSION_EDIT: return doc->crypt->p & PDF_PERM_CHANGE;
- case FZ_PERMISSION_ANNOTATE: return doc->crypt->p & PDF_PERM_NOTES;
+ case FZ_PERMISSION_EDIT: return doc->crypt->p & PDF_PERM_MODIFY;
+ case FZ_PERMISSION_ANNOTATE: return doc->crypt->p & PDF_PERM_ANNOTATE;
}
return 1;
}
+int
+pdf_document_permissions(fz_context *ctx, pdf_document *doc)
+{
+ if (doc->crypt)
+ return doc->crypt->p;
+ return PDF_DEFAULT_PERM_FLAGS;
+}
+
unsigned char *
pdf_crypt_key(fz_context *ctx, pdf_document *doc)
{