[gs-cvs] /home/tor/repos/mupdf - Add support to print information about encrypted pdfs.

sebras at hotmail.com sebras at hotmail.com
Mon Jun 29 18:28:15 PDT 2009


Tue Jun 30 01:27:50 UTC 2009  sebras at hotmail.com
  * Add support to print information about encrypted pdfs.

    M ./apps/pdfinfo.c -7 +33

--- old-mupdf/apps/pdfinfo.c	2009-06-30 01:28:15.000000000 +0000
+++ new-mupdf/apps/pdfinfo.c	2009-06-30 01:28:15.000000000 +0000
@@ -130,6 +130,9 @@
 			fz_obj *obj;
 		} info;
 		struct {
+			fz_obj *obj;
+		} crypt;
+		struct {
 			fz_rect *bbox;
 		} dim;
 		struct {
@@ -160,6 +163,7 @@
 };
 
 struct info *info = nil;
+struct info *cryptinfo = nil;
 struct info **dim = nil;
 int dims = 0;
 struct info **font = nil;
@@ -201,17 +205,33 @@
 
 	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 @@
 		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));
 }
 



More information about the gs-cvs mailing list