Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Page numbers in annotations. #2

Merged
merged 4 commits into from

2 participants

@avsm

And minor style fixes for the README and .gitignore.

I place these patches in the public domain. I haven't generalized list-annotations at all, and just hardcoded an all range. You may want to push this into the command-line spec too...

avsm added some commits
@avsm avsm build: add -annot flag to build flags c19f00d
@avsm avsm Add .gitignore for generated files 72a3203
@avsm avsm Markdown layout fixes, and note that OPAM installs the binary now a6ff553
@avsm avsm 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>
79afdd4
@avsm

PS: This works for Real World OCaml now and saved me a ton of time. Yay!

@avsm avsm referenced this pull request in ocaml/opam-repository
Merged

cpdf.0.7: install the `cpdf` binary as well as the library #1100

@johnwhitington johnwhitington merged commit 9208f20 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 16, 2013
  1. @avsm
  2. @avsm
  3. @avsm
  4. @avsm

    Alter the `list-annotations` output to include the page number.

    avsm authored
    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 page is out of date. Refresh to see the latest.
Showing with 37 additions and 17 deletions.
  1. +13 −0 .gitignore
  2. +1 −1  Makefile
  3. +12 −8 README.md
  4. +11 −8 cpdf.ml
View
13 .gitignore
@@ -0,0 +1,13 @@
+*.cmi
+*.cmo
+*.cma
+*.cmx
+*.cmxa
+*.top
+*.o
+*.a
+._bcdi/
+._ncdi/
+._d/
+cpdf
+*.annot
View
2  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
View
20 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)
-
View
19 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
Something went wrong with that request. Please try again.