From 24381a6a675c0ac6597f67d7961d8d57a2a755bd Mon Sep 17 00:00:00 2001 From: John Whitington Date: Mon, 29 May 2023 15:18:43 +0100 Subject: [PATCH] Deduplicate -list-annotations-json --- cpdfannot.ml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpdfannot.ml b/cpdfannot.ml index 7173da9..f0bf6c5 100644 --- a/cpdfannot.ml +++ b/cpdfannot.ml @@ -92,6 +92,7 @@ let get_annotations_json pdf range = let pairs = option_map (fun (p, n) -> if mem n range then Some (p, n) else None) pairs in let pages, pagenums = split pairs in let json = flatten (map2 (annotations_json_page calculate_pagenumber pdf) pages pagenums) in + let jsonobjnums : int list = map (function `List [_; `Int n; _] -> n | _ -> assert false) json in (*Printf.printf "%i extra roots to explore\n" (length extra); iter (fun x -> Pdfe.log "%s\n\n" (Pdfwrite.string_of_pdf x)) extra;*) let extra = @@ -110,6 +111,11 @@ let get_annotations_json pdf range = (Pdfwrite.string_of_pdf x);*) r) !extra))) in + let extra = + option_map + (function `List [`Int n; _] as json -> if mem n jsonobjnums then None else Some json | _ -> assert false) + extra + in let header = `List [`Int 0;