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
|
map (fun rs -> Pdfpage.pdf_of_pages pdf rs) ranges
|
||||||
|
|
||||||
(* Output information for each page *)
|
(* Output information for each page *)
|
||||||
let output_page_info pdf =
|
let output_page_info pdf range =
|
||||||
let pages = Pdfpage.pages_of_pagetree pdf
|
let pages = Pdfpage.pages_of_pagetree pdf
|
||||||
and labels = Pdfpagelabels.read pdf in
|
and labels = Pdfpagelabels.read pdf in
|
||||||
let getbox page box =
|
let getbox page box =
|
||||||
|
@ -1290,18 +1290,19 @@ let output_page_info pdf =
|
||||||
and rotation page =
|
and rotation page =
|
||||||
Pdfpage.int_of_rotation page.Pdfpage.rotate
|
Pdfpage.int_of_rotation page.Pdfpage.rotate
|
||||||
in
|
in
|
||||||
for pnum = 1 to Pdfpage.endpage pdf do
|
List.iter
|
||||||
let page = select pnum pages in
|
(fun pnum ->
|
||||||
Printf.printf "Page %i:\n" pnum;
|
let page = select pnum pages in
|
||||||
Printf.printf "Label: %s\n"
|
Printf.printf "Page %i:\n" pnum;
|
||||||
(try Pdfpagelabels.pagelabeltext_of_pagenumber pnum labels with Not_found -> "");
|
Printf.printf "Label: %s\n"
|
||||||
Printf.printf "MediaBox: %s\n" (getbox page "/MediaBox");
|
(try Pdfpagelabels.pagelabeltext_of_pagenumber pnum labels with Not_found -> "");
|
||||||
Printf.printf "CropBox: %s\n" (getbox page "/CropBox");
|
Printf.printf "MediaBox: %s\n" (getbox page "/MediaBox");
|
||||||
Printf.printf "BleedBox: %s\n" (getbox page "/BleedBox");
|
Printf.printf "CropBox: %s\n" (getbox page "/CropBox");
|
||||||
Printf.printf "TrimBox: %s\n" (getbox page "/TrimBox");
|
Printf.printf "BleedBox: %s\n" (getbox page "/BleedBox");
|
||||||
Printf.printf "ArtBox: %s\n" (getbox page "/ArtBox");
|
Printf.printf "TrimBox: %s\n" (getbox page "/TrimBox");
|
||||||
Printf.printf "Rotation: %i\n" (rotation page)
|
Printf.printf "ArtBox: %s\n" (getbox page "/ArtBox");
|
||||||
done
|
Printf.printf "Rotation: %i\n" (rotation page))
|
||||||
|
range
|
||||||
|
|
||||||
(* Does the page have a defined box e.g "/CropBox" *)
|
(* Does the page have a defined box e.g "/CropBox" *)
|
||||||
let hasbox pdf page boxname =
|
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} *)
|
(** {2 Page geometry} *)
|
||||||
|
|
||||||
(** Print page info (Mediabox etc) to standard output. *)
|
(** 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 *)
|
(** True if a given page in a PDF has a given box *)
|
||||||
val hasbox : Pdf.t -> int -> string -> bool
|
val hasbox : Pdf.t -> int -> string -> bool
|
||||||
|
|
|
@ -3,7 +3,7 @@ let demo = false
|
||||||
let noncomp = false
|
let noncomp = false
|
||||||
let major_version = 1
|
let major_version = 1
|
||||||
let minor_version = 8
|
let minor_version = 8
|
||||||
let version_date = "(unreleased, 18th April 2014)"
|
let version_date = "(unreleased, 11th August 2014)"
|
||||||
|
|
||||||
open Pdfutil
|
open Pdfutil
|
||||||
open Pdfio
|
open Pdfio
|
||||||
|
@ -2837,7 +2837,13 @@ let go () =
|
||||||
let pdf = decrypt_if_necessary input (Some Info) pdf in
|
let pdf = decrypt_if_necessary input (Some Info) pdf in
|
||||||
Cpdf.output_info args.encoding pdf
|
Cpdf.output_info args.encoding pdf
|
||||||
| Some PageInfo ->
|
| 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 ->
|
| Some Metadata ->
|
||||||
Cpdf.print_metadata (get_single_pdf (Some Metadata) true)
|
Cpdf.print_metadata (get_single_pdf (Some Metadata) true)
|
||||||
| Some Fonts ->
|
| Some Fonts ->
|
||||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
Loading…
Reference in New Issue