From f7a4b91d86010431e7d6c819fd8a32bc290e8037 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 19 Jan 2023 11:34:07 +0800 Subject: [PATCH] more --- cpdfannot.ml | 17 ++++++++++++++--- cpdfmanual.tex | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cpdfannot.ml b/cpdfannot.ml index 1574c09..551aea4 100644 --- a/cpdfannot.ml +++ b/cpdfannot.ml @@ -149,13 +149,24 @@ let list_annotations_json range pdf = let extra = map (fun n -> - `List [`Int ~-n; Cpdfjson.json_of_object ~utf8:true ~clean_strings:true pdf (fun _ -> ()) ~no_stream_data:false ~parse_content:false (Pdf.lookup_obj pdf n)]) - (setify (flatten (map (Pdf.objects_referenced [] [] pdf) extra))) + `List + [`Int ~-n; + Cpdfjson.json_of_object ~utf8:true ~clean_strings:true pdf (fun _ -> ()) + ~no_stream_data:false ~parse_content:false (Pdf.lookup_obj pdf n)]) + (setify + (flatten + (map + (fun x -> + let r = Pdf.objects_referenced [] [] pdf x in + (*Printf.printf "%i extra for annot %s\n" (length r) + (Pdfwrite.string_of_pdf x);*) r) + extra))) in let header = `List [`Int 0; - Cpdfjson.json_of_object ~utf8:true ~clean_strings:true pdf (fun _ -> ()) ~no_stream_data:false ~parse_content:false + Cpdfjson.json_of_object ~utf8:true ~clean_strings:true pdf (fun _ -> ()) + ~no_stream_data:false ~parse_content:false (Pdf.Dictionary ["/CPDFJSONannotformatversion", Pdf.Integer 1])] in let json = `List ([header] @ json @ extra) in diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 0d8055b..b78b8f9 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -3,7 +3,7 @@ %Document -draw and friends %Document -png -jpeg %Document -list-annotations[-json] now obey page range -%Document round-tripping of annotations, supersede -copy-annotations +%Document round-tripping of annotations, supersede -copy-annotations. Mark -clean-strings as deprecated since can fail to round-trip binary strings which begin with a BOM. \documentclass{book} % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf, % dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.