more
This commit is contained in:
parent
25f1c3613e
commit
322fb7241b
1
Changes
1
Changes
|
@ -13,6 +13,7 @@ Extended features:
|
||||||
o Allow -utf8 with -split-bookmarks -o @B.pdf to produce UTF8 filenames
|
o Allow -utf8 with -split-bookmarks -o @B.pdf to produce UTF8 filenames
|
||||||
o -merge-add-bookmarks now works with unicode filenames
|
o -merge-add-bookmarks now works with unicode filenames
|
||||||
o Better transformation of some annotation types
|
o Better transformation of some annotation types
|
||||||
|
o -list-annotations[-json] now respects page range
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
|
|
||||||
|
|
10
cpdfannot.ml
10
cpdfannot.ml
|
@ -65,17 +65,19 @@ let annotations_json_page pdf page pagenum =
|
||||||
(map (Pdf.direct pdf) annots)
|
(map (Pdf.direct pdf) annots)
|
||||||
| _ -> []
|
| _ -> []
|
||||||
|
|
||||||
let list_annotations_json pdf =
|
let list_annotations_json range pdf =
|
||||||
let module J = Cpdfyojson.Safe in
|
let module J = Cpdfyojson.Safe in
|
||||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||||
let pagenums = indx pages in
|
let pagenums = indx pages in
|
||||||
|
let pairs = combine pages pagenums 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 json = `List (flatten (map2 (annotations_json_page pdf) pages pagenums)) in
|
let json = `List (flatten (map2 (annotations_json_page pdf) pages pagenums)) in
|
||||||
J.pretty_to_channel stdout json
|
J.pretty_to_channel stdout json
|
||||||
|
|
||||||
let list_annotations ~json encoding pdf =
|
let list_annotations ~json range encoding pdf =
|
||||||
let range = Cpdfpagespec.parse_pagespec pdf "all" in
|
|
||||||
if json
|
if json
|
||||||
then list_annotations_json pdf
|
then list_annotations_json range pdf
|
||||||
else Cpdfpage.iter_pages (list_page_annotations encoding pdf) pdf range
|
else Cpdfpage.iter_pages (list_page_annotations encoding pdf) pdf range
|
||||||
|
|
||||||
(* Return annotations *)
|
(* Return annotations *)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(** Annotations *)
|
(** Annotations *)
|
||||||
|
|
||||||
(** List the annotations to standard output in a given encoding. See cpdfmanual.pdf for the format details. *)
|
(** List the annotations to standard output in a given encoding. See cpdfmanual.pdf for the format details. *)
|
||||||
val list_annotations : json:bool -> Cpdfmetadata.encoding -> Pdf.t -> unit
|
val list_annotations : json:bool -> int list -> Cpdfmetadata.encoding -> Pdf.t -> unit
|
||||||
|
|
||||||
(** Return the annotations as a (pagenumber, content) list *)
|
(** Return the annotations as a (pagenumber, content) list *)
|
||||||
val get_annotations : Cpdfmetadata.encoding -> Pdf.t -> (int * string) list
|
val get_annotations : Cpdfmetadata.encoding -> Pdf.t -> (int * string) list
|
||||||
|
|
|
@ -3966,7 +3966,9 @@ let go () =
|
||||||
| _ -> error "copy-annotations: No input file specified"
|
| _ -> error "copy-annotations: No input file specified"
|
||||||
end
|
end
|
||||||
| Some ListAnnotations ->
|
| Some ListAnnotations ->
|
||||||
Cpdfannot.list_annotations ~json:args.format_json args.encoding (get_single_pdf args.op true)
|
let pdf = get_single_pdf args.op true in
|
||||||
|
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||||
|
Cpdfannot.list_annotations ~json:args.format_json range args.encoding pdf
|
||||||
| Some Shift ->
|
| Some Shift ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
%Document -font-ttf
|
%Document -font-ttf
|
||||||
%Document -draw and friends
|
%Document -draw and friends
|
||||||
%Document -png -jpeg
|
%Document -png -jpeg
|
||||||
|
%Document -list-annotations[-json] now obey page range
|
||||||
\documentclass{book}
|
\documentclass{book}
|
||||||
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,
|
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,
|
||||||
% dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.
|
% dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.
|
||||||
|
|
Loading…
Reference in New Issue