Added range functionality to -page-info

This commit is contained in:
John Whitington 2014-08-11 14:05:07 +01:00
parent 62b55d6c28
commit 311b8c1dca
4 changed files with 23 additions and 16 deletions

View File

@ -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,7 +1290,8 @@ let output_page_info pdf =
and rotation page =
Pdfpage.int_of_rotation page.Pdfpage.rotate
in
for pnum = 1 to Pdfpage.endpage pdf do
List.iter
(fun pnum ->
let page = select pnum pages in
Printf.printf "Page %i:\n" pnum;
Printf.printf "Label: %s\n"
@ -1300,8 +1301,8 @@ let output_page_info pdf =
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
Printf.printf "Rotation: %i\n" (rotation page))
range
(* Does the page have a defined box e.g "/CropBox" *)
let hasbox pdf page boxname =

View File

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

View File

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

Binary file not shown.