Exclude unwanted annotations

This commit is contained in:
John Whitington 2023-05-29 20:07:42 +01:00
parent 24381a6a67
commit e17982fca2
1 changed files with 7 additions and 0 deletions

View File

@ -54,6 +54,12 @@ let rewrite_destinations f pdf annot =
end end
| None -> annot | None -> annot
(* We exclude the same annotations as the XFDF spec does *)
let excluded pdf annot =
match Pdf.lookup_direct pdf "/Subtype" annot with
| Some (Pdf.Name ("/Movie" | "/Widget" | "/Screen" | "/PrinterMark" | "/TrapNet")) -> true
| _ -> false
let extra = ref [] let extra = ref []
let annotations_json_page calculate_pagenumber pdf page pagenum = let annotations_json_page calculate_pagenumber pdf page pagenum =
@ -64,6 +70,7 @@ let annotations_json_page calculate_pagenumber pdf page pagenum =
begin match annot with begin match annot with
| Pdf.Indirect objnum -> | Pdf.Indirect objnum ->
let annot = Pdf.direct pdf annot in let annot = Pdf.direct pdf annot in
if excluded pdf annot then None else
let annot = let annot =
rewrite_destinations rewrite_destinations
(fun i -> calculate_pagenumber (Pdfdest.Fit (Pdfdest.PageObject i))) (fun i -> calculate_pagenumber (Pdfdest.Fit (Pdfdest.PageObject i)))