From c19f00d71423c00b941b0637024a153e3794a4cc Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Mon, 16 Sep 2013 13:17:40 +0100 Subject: [PATCH 1/4] build: add -annot flag to build flags --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 72a3203891de51761436c9983ee145485ee26f45 Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Mon, 16 Sep 2013 13:18:52 +0100 Subject: [PATCH 2/4] Add .gitignore for generated files --- .gitignore | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .gitignore 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 From a6ff553210fc8ab6422fc7c5e1f8849ebb4b693e Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Mon, 16 Sep 2013 13:43:55 +0100 Subject: [PATCH 3/4] Markdown layout fixes, and note that OPAM installs the binary now Closes #1 and OCamlPro/opam-repository#1100 --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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) - From 79afdd42e45ed9597fca538588952eb8b9399139 Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Mon, 16 Sep 2013 13:46:00 +0100 Subject: [PATCH 4/4] 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: \n`. Grep users will need to be careful to deal with multiline comments, though. Signed-off-by: Anil Madhavapeddy --- cpdf.ml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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