summaryrefslogtreecommitdiff
path: root/apps/pdfinfo.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2009-06-30 03:27:50 +0200
committerSebastian Rasmussen <sebras@hotmail.com>2009-06-30 03:27:50 +0200
commit4e338fa918babb5e49e2323d057f70d94fb44cd2 (patch)
tree96fd2a6c4208c54ba5b2ef31959a6b7aa92e219e /apps/pdfinfo.c
parent4485d4cfd839858525ac0ca2fb4a7cd7e4cebeaf (diff)
downloadmupdf-4e338fa918babb5e49e2323d057f70d94fb44cd2.tar.xz
Add support to print information about encrypted pdfs.
Diffstat (limited to 'apps/pdfinfo.c')
-rw-r--r--apps/pdfinfo.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c
index 215d5ddf..4d3ed2bc 100644
--- a/apps/pdfinfo.c
+++ b/apps/pdfinfo.c
@@ -130,6 +130,9 @@ struct info
fz_obj *obj;
} info;
struct {
+ fz_obj *obj;
+ } crypt;
+ struct {
fz_rect *bbox;
} dim;
struct {
@@ -160,6 +163,7 @@ struct info
};
struct info *info = nil;
+struct info *cryptinfo = nil;
struct info **dim = nil;
int dims = 0;
struct info **font = nil;
@@ -201,17 +205,33 @@ gatherglobalinfo()
info->page = -1;
info->pageref = nil;
- info->ref = fz_dictgets(src->trailer, "Info");
-
+ info->ref = nil;
info->u.info.obj = nil;
- if (!info->ref)
- return;
+ if (src->info)
+ {
+ info->ref = fz_dictgets(src->trailer, "Info");
+ if (!fz_isdict(info->ref) && !fz_isindirect(info->ref))
+ die(fz_throw("not an indirect info object"));
+
+ info->u.info.obj = src->info;
+ }
+
+ cryptinfo = fz_malloc(sizeof (struct info));
- if (!fz_isdict(info->ref) && !fz_isindirect(info->ref))
- die(fz_throw("not an indirect info object"));
+ cryptinfo->page = -1;
+ cryptinfo->pageref = nil;
+ cryptinfo->ref = nil;
+ cryptinfo->u.crypt.obj = nil;
- info->u.info.obj = src->info;
+ if (src->crypt)
+ {
+ cryptinfo->ref = fz_dictgets(src->trailer, "Encrypt");
+ if (!fz_isdict(cryptinfo->ref) && !fz_isindirect(cryptinfo->ref))
+ die(fz_throw("not an indirect crypt object"));
+
+ cryptinfo->u.crypt.obj = src->crypt->encrypt;
+ }
}
fz_error
@@ -777,6 +797,12 @@ printglobalinfo(char *filename)
fz_debugobj(info->u.info.obj);
}
+ if (cryptinfo->u.crypt.obj)
+ {
+ printf("\nEncryption object (%d %d R):\n", fz_tonum(cryptinfo->ref), fz_togen(cryptinfo->ref));
+ fz_debugobj(cryptinfo->u.crypt.obj);
+ }
+
printf("\nPages: %d\n\n", pdf_getpagecount(srcpages));
}