diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59dc76d --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.cmi +*.cmo +*.cma +*.cmx +*.cmxa +*.top +*.o +*.a +._bcdi/ +._ncdi/ +._d/ +cpdf +*.annot diff --git a/Makefile b/Makefile index d706771..ac1c11d 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ MODS = cpdfstrftime cpdf cpdfcommand SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml RESULT = cpdf - +ANNOTATE = true PACKS = camlpdf OCAMLNCFLAGS = -g diff --git a/README.md b/README.md index 27d5f42..d97737a 100644 --- a/README.md +++ b/README.md @@ -32,30 +32,34 @@ If you are using the OPAM package manager: these can be installed by: -opam install ocamlfind camlpdf +``` +opam install camlpdf +``` To build -------- -1. Type 'make' to make the cpdf executable and the library +1. Type `make` to make the cpdf executable and the library -2. Type 'make install' to install the OCaml cpdf library. +2. Type `make install` to install the OCaml cpdf library. -The cpdf executable should be manually placed somewhere suitable. +The `cpdf` executable should be manually placed somewhere suitable. -Alternatively, the library only can be installed by +Alternatively, the library and command-line binary can be installed by +``` opam install cpdf +``` + Documentation ------------- -The file cpdfmanual.pdf in this folder is the documentation for the command -line tools. The documentation for the cpdf OCaml library is in doc/html/cpdf/ +The file `cpdfmanual.pdf` in this folder is the documentation for the command +line tools. The documentation for the cpdf OCaml library is in `doc/html/cpdf/` in this folder once the library has been built. Contact ------- [contact@coherentgraphics.co.uk](contact@coherentgraphics.co.uk) - diff --git a/cpdf.ml b/cpdf.ml index 7862e3f..fce62ba 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -2253,21 +2253,24 @@ let get_annotation_string encoding pdf annot = | 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 - flprint "------------------------------------------------------------------------\n"; - flprint s; - flprint "\n" + match s with + | "" -> () + | 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 | 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 pages = Pdfpage.pages_of_pagetree pdf in - iter (list_page_annotations encoding pdf) pages + let range = parse_pagespec pdf "all" in + iter_pages (list_page_annotations encoding pdf) pdf range let get_annotations encoding pdf = let pages = Pdfpage.pages_of_pagetree pdf in