Browse code

Add more PDF properties

Shawn Webb authored on 2014/06/28 01:43:23
Showing 2 changed files
... ...
@@ -112,6 +112,9 @@ static void Subject_cb(struct pdf_struct *, struct pdf_obj *, struct pdfname_act
112 112
 static void Keywords_cb(struct pdf_struct *, struct pdf_obj *, struct pdfname_action *);
113 113
 static void Pages_cb(struct pdf_struct *, struct pdf_obj *, struct pdfname_action *);
114 114
 static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act);
115
+static void RichMedia_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act);
116
+static void AcroForm_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act);
117
+static void XFA_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act);
115 118
 /* End PDF statistics callbacks and related */
116 119
 
117 120
 static int xrefCheck(const char *xref, const char *eof)
... ...
@@ -1341,7 +1344,10 @@ static struct pdfname_action pdfname_actions[] = {
1341 1341
     {"Keywords", OBJ_DICT, STATE_NONE, STATE_NONE, Keywords_cb},
1342 1342
     {"Subject", OBJ_DICT, STATE_NONE, STATE_NONE, Subject_cb},
1343 1343
     {"Pages", OBJ_DICT, STATE_NONE, STATE_NONE, Pages_cb},
1344
-    {"Colors", OBJ_DICT, STATE_NONE, STATE_NONE, Colors_cb}
1344
+    {"Colors", OBJ_DICT, STATE_NONE, STATE_NONE, Colors_cb},
1345
+    {"RichMedia", OBJ_DICT, STATE_NONE, STATE_NONE, RichMedia_cb},
1346
+    {"AcroForm", OBJ_DICT, STATE_NONE, STATE_NONE, AcroForm_cb},
1347
+    {"XFA", OBJ_DICT, STATE_NONE, STATE_NONE, XFA_cb}
1345 1348
 };
1346 1349
 
1347 1350
 #define KNOWN_FILTERS ((1 << OBJ_FILTER_AH) | (1 << OBJ_FILTER_RL) | (1 << OBJ_FILTER_A85) | (1 << OBJ_FILTER_FLATE) | (1 << OBJ_FILTER_LZW) | (1 << OBJ_FILTER_FAX) | (1 << OBJ_FILTER_DCT) | (1 << OBJ_FILTER_JPX) | (1 << OBJ_FILTER_CRYPT))
... ...
@@ -3050,6 +3056,30 @@ static void Subject_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfna
3050 3050
 #endif
3051 3051
 }
3052 3052
 
3053
+static void RichMedia_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
3054
+{
3055
+    if (!(pdf))
3056
+        return;
3057
+
3058
+    pdf->stats.nrichmedia++;
3059
+}
3060
+
3061
+static void AcroForm_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
3062
+{
3063
+    if (!(pdf))
3064
+        return;
3065
+
3066
+    pdf->stats.nacroform++;
3067
+}
3068
+
3069
+static void XFA_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
3070
+{
3071
+    if (!(pdf))
3072
+        return;
3073
+
3074
+    pdf->stats.nxfa++;
3075
+}
3076
+
3053 3077
 static void Pages_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
3054 3078
 {
3055 3079
 #if HAVE_JSON
... ...
@@ -3277,6 +3307,12 @@ static void pdf_export_json(struct pdf_struct *pdf)
3277 3277
         cli_jsonint(pdfobj, "LaunchCount", pdf->stats.nlaunch);
3278 3278
     if (pdf->stats.npage)
3279 3279
         cli_jsonint(pdfobj, "PageCount", pdf->stats.npage);
3280
+    if (pdf->stats.nrichmedia)
3281
+        cli_jsonint(pdfobj, "RichMediaCount", pdf->stats.nrichmedia);
3282
+    if (pdf->stats.nacroform)
3283
+        cli_jsonint(pdfobj, "AcroFormCount", pdf->stats.nacroform);
3284
+    if (pdf->stats.nxfa)
3285
+        cli_jsonint(pdfobj, "XFACount", pdf->stats.nxfa);
3280 3286
     if (pdf->flags & (1 << BAD_PDF_VERSION))
3281 3287
         cli_jsonbool(pdfobj, "BadVersion", 1);
3282 3288
     if (pdf->flags & (1 << BAD_PDF_HEADERPOS))
... ...
@@ -85,6 +85,9 @@ struct pdf_stats {
85 85
     int32_t nopenaction;      /* Number of OpenAction objects */
86 86
     int32_t nlaunch;          /* Number of Launch objects */
87 87
     int32_t npage;            /* Number of Page objects */
88
+    int32_t nrichmedia;       /* Number of RichMedia objects */
89
+    int32_t nacroform;        /* Number of AcroForm objects */
90
+    int32_t nxfa;             /* Number of XFA objects */
88 91
     char *author;             /* Author of the PDF */
89 92
     char *creator;            /* Application used to create the PDF */
90 93
     char *producer;           /* Application used to produce the PDF */