Browse code

Add the PDF version to the JSON properties

Shawn Webb authored on 2014/07/01 03:06:37
Showing 1 changed files
... ...
@@ -2339,6 +2339,7 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset)
2339 2339
     unsigned i, alerts = 0;
2340 2340
 #if HAVE_JSON
2341 2341
     json_object *pdfobj=NULL;
2342
+    char *begin, *end, *p1;
2342 2343
 #endif
2343 2344
 
2344 2345
     cli_dbgmsg("in cli_pdf(%s)\n", dir);
... ...
@@ -2378,6 +2379,21 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset)
2378 2378
         if (pdfobj)
2379 2379
             cli_jsonbool(pdfobj, "BadVersion", 1);
2380 2380
 #endif
2381
+    } else {
2382
+#if HAVE_JSON
2383
+        if (pdfobj) {
2384
+            begin = (char *)(pdfver+5);
2385
+            end = begin+2;
2386
+            strtoul(end, &end, 10);
2387
+            p1 = cli_calloc((end - begin) + 2, 1);
2388
+            if (p1) {
2389
+                strncpy(p1, begin, end - begin);
2390
+                p1[end - begin] = '\0';
2391
+                cli_jsonstr(pdfobj, "PDFVersion", p1);
2392
+                free(p1);
2393
+            }
2394
+        }
2395
+#endif
2381 2396
     }
2382 2397
 
2383 2398
     if (pdfver != start || offset) {
... ...
@@ -3099,15 +3115,6 @@ static void Pages_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname
3099 3099
     if (!(pdfobj))
3100 3100
         return;
3101 3101
 
3102
-    begin = cli_memstr(objstart, objsz, "<<", 2);
3103
-    if (!(begin))
3104
-        return;
3105
-
3106
-    dict = pdf_parse_dict(pdf, obj, objsz, begin, NULL);
3107
-    if (dict) {
3108
-        pdf_free_dict(dict);
3109
-    }
3110
-
3111 3102
     begin = cli_memstr(objstart, objsz, "/Kids", 5);
3112 3103
     if (!(begin))
3113 3104
         return;