Deduplicate -list-annotations-json

This commit is contained in:
John Whitington 2023-05-29 15:18:43 +01:00
parent a216723708
commit 24381a6a67
1 changed files with 6 additions and 0 deletions

View File

@ -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 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 pages, pagenums = split pairs in
let json = flatten (map2 (annotations_json_page calculate_pagenumber pdf) pages pagenums) 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); (*Printf.printf "%i extra roots to explore\n" (length extra);
iter (fun x -> Pdfe.log "%s\n\n" (Pdfwrite.string_of_pdf x)) extra;*) iter (fun x -> Pdfe.log "%s\n\n" (Pdfwrite.string_of_pdf x)) extra;*)
let extra = let extra =
@ -110,6 +111,11 @@ let get_annotations_json pdf range =
(Pdfwrite.string_of_pdf x);*) r) (Pdfwrite.string_of_pdf x);*) r)
!extra))) !extra)))
in 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 = let header =
`List `List
[`Int 0; [`Int 0;