This commit is contained in:
John Whitington 2023-01-19 11:34:07 +08:00
parent 883dba9bcc
commit f7a4b91d86
2 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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.