Merge pull request #2 from avsm/annotation-page-numbers

Page numbers in annotations via asvm. Will update the manual for 1.8 release time (it will be found by the standard manual tests).
This commit is contained in:
johnwhitington 2013-09-16 11:09:40 -07:00
commit 9208f206be
4 changed files with 37 additions and 17 deletions

13
.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
*.cmi
*.cmo
*.cma
*.cmx
*.cmxa
*.top
*.o
*.a
._bcdi/
._ncdi/
._d/
cpdf
*.annot

View File

@ -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 File

@ -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)

15
cpdf.ml
View File

@ -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";
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