Alter the `list-annotations` output to include the page number.
Also make the output format more succinct to make it grep/awk-friendly. The new format is `Page: <comment>\n`. Grep users will need to be careful to deal with multiline comments, though. Signed-off-by: Anil Madhavapeddy <anil@recoil.org>
This commit is contained in:
parent
a6ff553210
commit
79afdd42e4
19
cpdf.ml
19
cpdf.ml
|
@ -2253,21 +2253,24 @@ let get_annotation_string encoding pdf annot =
|
||||||
| Some (Pdf.String s) -> encode_output encoding s
|
| Some (Pdf.String s) -> encode_output encoding s
|
||||||
| _ -> ""
|
| _ -> ""
|
||||||
|
|
||||||
let print_annotation encoding pdf s =
|
let print_annotation encoding pdf num s =
|
||||||
let s = get_annotation_string encoding pdf s in
|
let s = get_annotation_string encoding pdf s in
|
||||||
flprint "------------------------------------------------------------------------\n";
|
match s with
|
||||||
flprint s;
|
| "" -> ()
|
||||||
flprint "\n"
|
| s ->
|
||||||
|
flprint (Printf.sprintf "Page %d: " num);
|
||||||
|
flprint s;
|
||||||
|
flprint "\n"
|
||||||
|
|
||||||
let list_page_annotations encoding pdf page =
|
let list_page_annotations encoding pdf num page =
|
||||||
match Pdf.lookup_direct pdf "/Annots" page.Pdfpage.rest with
|
match Pdf.lookup_direct pdf "/Annots" page.Pdfpage.rest with
|
||||||
| Some (Pdf.Array annots) ->
|
| Some (Pdf.Array annots) ->
|
||||||
iter (print_annotation encoding pdf) (map (Pdf.direct pdf) annots)
|
iter (print_annotation encoding pdf num) (map (Pdf.direct pdf) annots)
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
|
|
||||||
let list_annotations encoding pdf =
|
let list_annotations encoding pdf =
|
||||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
let range = parse_pagespec pdf "all" in
|
||||||
iter (list_page_annotations encoding pdf) pages
|
iter_pages (list_page_annotations encoding pdf) pdf range
|
||||||
|
|
||||||
let get_annotations encoding pdf =
|
let get_annotations encoding pdf =
|
||||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||||
|
|
Loading…
Reference in New Issue