diff --git a/cpdf.ml b/cpdf.ml index 4be3b77..d2590ca 100644 --- a/cpdf.ml +++ b/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 = diff --git a/cpdf.mli b/cpdf.mli index c83dffa..9c4f6d8 100644 --- a/cpdf.mli +++ b/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 diff --git a/cpdfcommand.ml b/cpdfcommand.ml index e4f8553..06624a3 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -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 -> diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index 621f37f..92b0dbc 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ