Added -revisions to count the number of revisions in a document
This commit is contained in:
parent
40b650a98d
commit
c08d9d68fa
|
@ -154,6 +154,7 @@ type op =
|
||||||
| AddPageLabels
|
| AddPageLabels
|
||||||
| RemovePageLabels
|
| RemovePageLabels
|
||||||
| PrintPageLabels
|
| PrintPageLabels
|
||||||
|
| Revisions
|
||||||
|
|
||||||
let string_of_op = function
|
let string_of_op = function
|
||||||
| CopyFont _ -> "CopyFont"
|
| CopyFont _ -> "CopyFont"
|
||||||
|
@ -254,6 +255,7 @@ let string_of_op = function
|
||||||
| AddPageLabels -> "AddPageLabels"
|
| AddPageLabels -> "AddPageLabels"
|
||||||
| RemovePageLabels -> "RemovePageLabels"
|
| RemovePageLabels -> "RemovePageLabels"
|
||||||
| PrintPageLabels -> "PrintPageLabels"
|
| PrintPageLabels -> "PrintPageLabels"
|
||||||
|
| Revisions -> "Revisions"
|
||||||
|
|
||||||
(* Inputs: filename, pagespec. *)
|
(* Inputs: filename, pagespec. *)
|
||||||
type input_kind =
|
type input_kind =
|
||||||
|
@ -554,7 +556,7 @@ performed is checked to see if it's allowable under the permissions regime. *)
|
||||||
bans list in the input file, the operation cannot proceed. Other operations
|
bans list in the input file, the operation cannot proceed. Other operations
|
||||||
cannot proceed at all without owner password. *)
|
cannot proceed at all without owner password. *)
|
||||||
let banned banlist = function
|
let banned banlist = function
|
||||||
| Fonts | Info | Metadata | PageInfo | CountPages
|
| Fonts | Info | Metadata | PageInfo | Revisions | CountPages
|
||||||
| ListAttachedFiles | ListAnnotationsMore | ListAnnotations
|
| ListAttachedFiles | ListAnnotationsMore | ListAnnotations
|
||||||
| ListBookmarks | ImageResolution _ | MissingFonts
|
| ListBookmarks | ImageResolution _ | MissingFonts
|
||||||
| PrintPageLabels | Clean | Compress | Decompress
|
| PrintPageLabels | Clean | Compress | Decompress
|
||||||
|
@ -1732,6 +1734,9 @@ and specs =
|
||||||
("-pages",
|
("-pages",
|
||||||
Arg.Unit (setop CountPages),
|
Arg.Unit (setop CountPages),
|
||||||
" Count pages");
|
" Count pages");
|
||||||
|
("-revisions",
|
||||||
|
Arg.Unit (setop Revisions),
|
||||||
|
" Count number of revisions");
|
||||||
("-list-attached-files",
|
("-list-attached-files",
|
||||||
Arg.Unit (setop ListAttachedFiles),
|
Arg.Unit (setop ListAttachedFiles),
|
||||||
" List attached files");
|
" List attached files");
|
||||||
|
@ -2973,6 +2978,14 @@ let go () =
|
||||||
in
|
in
|
||||||
let pdf = decrypt_if_necessary input (Some CountPages) pdf in
|
let pdf = decrypt_if_necessary input (Some CountPages) pdf in
|
||||||
output_page_count pdf
|
output_page_count pdf
|
||||||
|
| Some Revisions ->
|
||||||
|
let input =
|
||||||
|
match args.inputs with
|
||||||
|
(InFile inname, _, _, _, _)::_ -> Pdfio.input_of_channel (open_in_bin inname)
|
||||||
|
| (StdIn, _, _, _, _)::_ -> Pdfio.input_of_channel stdin
|
||||||
|
| _ -> raise (Arg.Bad "Revisions: must be a filename or stdin")
|
||||||
|
in
|
||||||
|
Printf.printf "%i\n%!" (Pdfread.revisions input)
|
||||||
| Some Clean ->
|
| Some Clean ->
|
||||||
begin match args.out with
|
begin match args.out with
|
||||||
| (File _ | Stdout) ->
|
| (File _ | Stdout) ->
|
||||||
|
|
Loading…
Reference in New Issue