more
This commit is contained in:
parent
e918630ea4
commit
3ed74079c8
1
Changes
1
Changes
|
@ -1,7 +1,6 @@
|
|||
2.5 (Upcoming 2022)
|
||||
|
||||
o Output annotations in JSON form with -list-annotations-json
|
||||
o Load annotations in JSON form with -add-annotations-json
|
||||
o Basic merging of AcroForms
|
||||
o Output bookmarks in JSON format with -list-bookmarks-json
|
||||
o Load bookmarks in JSON format with -add-bookmarks-json
|
||||
|
|
17
cpdf.ml
17
cpdf.ml
|
@ -2621,9 +2621,22 @@ let list_page_annotations encoding pdf num page =
|
|||
iter (print_annotation encoding pdf num) (map (Pdf.direct pdf) annots)
|
||||
| _ -> ()
|
||||
|
||||
let list_annotations encoding pdf =
|
||||
let annotations_json_page pdf page =
|
||||
match Pdf.lookup_direct pdf "/Annots" page.Pdfpage.rest with
|
||||
| Some (Pdf.Array annots) ->
|
||||
map (Cpdfjson.json_of_object pdf (fun _ -> ()) false false) (map (Pdf.direct pdf) annots)
|
||||
| _ -> []
|
||||
|
||||
let list_annotations_json pdf =
|
||||
let module J = Cpdfyojson.Safe in
|
||||
let json = `List (flatten (map (annotations_json_page pdf) (Pdfpage.pages_of_pagetree pdf))) in
|
||||
J.pretty_to_channel stdout json
|
||||
|
||||
let list_annotations ~json encoding pdf =
|
||||
let range = Cpdfpagespec.parse_pagespec pdf "all" in
|
||||
iter_pages (list_page_annotations encoding pdf) pdf range
|
||||
if json
|
||||
then list_annotations_json pdf
|
||||
else iter_pages (list_page_annotations encoding pdf) pdf range
|
||||
|
||||
let get_annotations encoding pdf =
|
||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||
|
|
2
cpdf.mli
2
cpdf.mli
|
@ -301,7 +301,7 @@ val padmultiple : int -> Pdf.t -> Pdf.t
|
|||
(** {2 Annotations} *)
|
||||
|
||||
(** List the annotations to standard output in a given encoding. See cpdfmanual.pdf for the format details. *)
|
||||
val list_annotations : encoding -> Pdf.t -> unit
|
||||
val list_annotations : json:bool -> encoding -> Pdf.t -> unit
|
||||
|
||||
(** Return the annotations as a (pagenumber, content) list *)
|
||||
val get_annotations : encoding -> Pdf.t -> (int * string) list
|
||||
|
|
|
@ -1071,7 +1071,7 @@ let setlistbookmarksjson () =
|
|||
args.format_json <- true
|
||||
|
||||
let setlistannotationsjson () =
|
||||
setop ListBookmarks ();
|
||||
setop ListAnnotations ();
|
||||
args.format_json <- true
|
||||
|
||||
let setstampon f =
|
||||
|
@ -3839,7 +3839,7 @@ let go () =
|
|||
| _ -> error "copy-annotations: No input file specified"
|
||||
end
|
||||
| Some ListAnnotations ->
|
||||
Cpdf.list_annotations args.encoding (get_single_pdf args.op true)
|
||||
Cpdf.list_annotations ~json:args.format_json args.encoding (get_single_pdf args.op true)
|
||||
| Some Shift ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
%Document the new JSON format, -j and new -output-json options
|
||||
%Document the new JSON format, -j and new -output-json options including UTF8
|
||||
%Document -decrypt-force
|
||||
%Document -collate
|
||||
%Document -impose and friends (inc. 0-w, 0-h for long ones, how lines scale etc., undefined if pages different sizes)
|
||||
%Document -bookmarks-json including mentioning UTF8
|
||||
%Document -list-annotations-json and -add-annotations-json
|
||||
%Document -list-annotations-json
|
||||
|
||||
\documentclass{book}
|
||||
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf etc.
|
||||
|
|
Loading…
Reference in New Issue