Added range functionality to -page-info
This commit is contained in:
parent
62b55d6c28
commit
311b8c1dca
27
cpdf.ml
27
cpdf.ml
|
@ -1271,7 +1271,7 @@ let split_on_bookmarks pdf level =
|
|||
map (fun rs -> Pdfpage.pdf_of_pages pdf rs) ranges
|
||||
|
||||
(* Output information for each page *)
|
||||
let output_page_info pdf =
|
||||
let output_page_info pdf range =
|
||||
let pages = Pdfpage.pages_of_pagetree pdf
|
||||
and labels = Pdfpagelabels.read pdf in
|
||||
let getbox page box =
|
||||
|
@ -1290,18 +1290,19 @@ let output_page_info pdf =
|
|||
and rotation page =
|
||||
Pdfpage.int_of_rotation page.Pdfpage.rotate
|
||||
in
|
||||
for pnum = 1 to Pdfpage.endpage pdf do
|
||||
let page = select pnum pages in
|
||||
Printf.printf "Page %i:\n" pnum;
|
||||
Printf.printf "Label: %s\n"
|
||||
(try Pdfpagelabels.pagelabeltext_of_pagenumber pnum labels with Not_found -> "");
|
||||
Printf.printf "MediaBox: %s\n" (getbox page "/MediaBox");
|
||||
Printf.printf "CropBox: %s\n" (getbox page "/CropBox");
|
||||
Printf.printf "BleedBox: %s\n" (getbox page "/BleedBox");
|
||||
Printf.printf "TrimBox: %s\n" (getbox page "/TrimBox");
|
||||
Printf.printf "ArtBox: %s\n" (getbox page "/ArtBox");
|
||||
Printf.printf "Rotation: %i\n" (rotation page)
|
||||
done
|
||||
List.iter
|
||||
(fun pnum ->
|
||||
let page = select pnum pages in
|
||||
Printf.printf "Page %i:\n" pnum;
|
||||
Printf.printf "Label: %s\n"
|
||||
(try Pdfpagelabels.pagelabeltext_of_pagenumber pnum labels with Not_found -> "");
|
||||
Printf.printf "MediaBox: %s\n" (getbox page "/MediaBox");
|
||||
Printf.printf "CropBox: %s\n" (getbox page "/CropBox");
|
||||
Printf.printf "BleedBox: %s\n" (getbox page "/BleedBox");
|
||||
Printf.printf "TrimBox: %s\n" (getbox page "/TrimBox");
|
||||
Printf.printf "ArtBox: %s\n" (getbox page "/ArtBox");
|
||||
Printf.printf "Rotation: %i\n" (rotation page))
|
||||
range
|
||||
|
||||
(* Does the page have a defined box e.g "/CropBox" *)
|
||||
let hasbox pdf page boxname =
|
||||
|
|
2
cpdf.mli
2
cpdf.mli
|
@ -292,7 +292,7 @@ val removetext : int list -> Pdf.t -> Pdf.t
|
|||
(** {2 Page geometry} *)
|
||||
|
||||
(** Print page info (Mediabox etc) to standard output. *)
|
||||
val output_page_info : Pdf.t -> unit
|
||||
val output_page_info : Pdf.t -> int list -> unit
|
||||
|
||||
(** True if a given page in a PDF has a given box *)
|
||||
val hasbox : Pdf.t -> int -> string -> bool
|
||||
|
|
|
@ -3,7 +3,7 @@ let demo = false
|
|||
let noncomp = false
|
||||
let major_version = 1
|
||||
let minor_version = 8
|
||||
let version_date = "(unreleased, 18th April 2014)"
|
||||
let version_date = "(unreleased, 11th August 2014)"
|
||||
|
||||
open Pdfutil
|
||||
open Pdfio
|
||||
|
@ -2837,7 +2837,13 @@ let go () =
|
|||
let pdf = decrypt_if_necessary input (Some Info) pdf in
|
||||
Cpdf.output_info args.encoding pdf
|
||||
| Some PageInfo ->
|
||||
Cpdf.output_page_info (get_single_pdf (Some PageInfo) true)
|
||||
begin match args.inputs, args.out with
|
||||
| (_, pagespec, _, _, _)::_, _ ->
|
||||
let pdf = get_single_pdf args.op true in
|
||||
let range = parse_pagespec pdf pagespec in
|
||||
Cpdf.output_page_info (get_single_pdf (Some PageInfo) true) range
|
||||
| _ -> error "list-bookmarks: bad command line"
|
||||
end
|
||||
| Some Metadata ->
|
||||
Cpdf.print_metadata (get_single_pdf (Some Metadata) true)
|
||||
| Some Fonts ->
|
||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
Loading…
Reference in New Issue