Add -bates-at-range
This commit is contained in:
parent
87998ea7ec
commit
db170b428b
12
cpdf.ml
12
cpdf.ml
|
@ -449,6 +449,18 @@ let rec validate_pagespec_inner n spec =
|
||||||
let validate_pagespec spec =
|
let validate_pagespec spec =
|
||||||
validate_pagespec_inner 100 spec
|
validate_pagespec_inner 100 spec
|
||||||
|
|
||||||
|
let rec parse_pagespec_without_pdf_inner n spec =
|
||||||
|
try
|
||||||
|
parse_pagespec_inner n (Pdf.empty ()) spec
|
||||||
|
with
|
||||||
|
PageSpecUnknownPage _ ->
|
||||||
|
if n < 500000
|
||||||
|
then parse_pagespec_without_pdf_inner (n * 2) spec
|
||||||
|
else raise (Pdf.PDFError "PageSpecUnknownPage")
|
||||||
|
|
||||||
|
let parse_pagespec_without_pdf spec =
|
||||||
|
parse_pagespec_without_pdf_inner 100 spec
|
||||||
|
|
||||||
(* Convert an integer list representing a set to a page specification, in order. *)
|
(* Convert an integer list representing a set to a page specification, in order. *)
|
||||||
let string_of_pagespec pdf = function
|
let string_of_pagespec pdf = function
|
||||||
| [] -> ""
|
| [] -> ""
|
||||||
|
|
2
cpdf.mli
2
cpdf.mli
|
@ -78,6 +78,8 @@ val string_of_pagespec : Pdf.t -> int list -> string
|
||||||
without supplying a PDF, and thus knowing how many pages there are in it. *)
|
without supplying a PDF, and thus knowing how many pages there are in it. *)
|
||||||
val validate_pagespec : string -> bool
|
val validate_pagespec : string -> bool
|
||||||
|
|
||||||
|
val parse_pagespec_without_pdf : string -> int list
|
||||||
|
|
||||||
(** [name_of_spec printf marks pdf splitlevel spec n filename startpage
|
(** [name_of_spec printf marks pdf splitlevel spec n filename startpage
|
||||||
endpage] makes format substitutions in [spec] to make an output file name:
|
endpage] makes format substitutions in [spec] to make an output file name:
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,7 @@ type input =
|
||||||
input_kind * string * string * string * bool ref * int option
|
input_kind * string * string * string * bool ref * int option
|
||||||
(* input kind, range, user_pw, owner_pw, was_decrypted_with_owner, revision *)
|
(* input kind, range, user_pw, owner_pw, was_decrypted_with_owner, revision *)
|
||||||
|
|
||||||
|
|
||||||
type output_method =
|
type output_method =
|
||||||
| NoOutputSpecified
|
| NoOutputSpecified
|
||||||
| Stdout
|
| Stdout
|
||||||
|
@ -536,6 +537,11 @@ let reset_arguments () =
|
||||||
(* Do not reset original_filename or cpdflin or was_encrypted or
|
(* Do not reset original_filename or cpdflin or was_encrypted or
|
||||||
* was_decrypted_with_owner or recrypt, since we want these to work across ANDs. *)
|
* was_decrypted_with_owner or recrypt, since we want these to work across ANDs. *)
|
||||||
|
|
||||||
|
let get_pagespec () =
|
||||||
|
match args.inputs with
|
||||||
|
| (_, ps, _, _, _, _)::_ -> ps
|
||||||
|
| _ -> error "No range specified for input, or specified too late."
|
||||||
|
|
||||||
let string_of_permission = function
|
let string_of_permission = function
|
||||||
| Pdfcrypt.NoEdit -> "No edit"
|
| Pdfcrypt.NoEdit -> "No edit"
|
||||||
| Pdfcrypt.NoPrint -> "No print"
|
| Pdfcrypt.NoPrint -> "No print"
|
||||||
|
@ -1067,6 +1073,14 @@ let setbatespad n =
|
||||||
let setbates n =
|
let setbates n =
|
||||||
args.bates <- n
|
args.bates <- n
|
||||||
|
|
||||||
|
(* Calculate -bates automatically so that n is applied to the first page in the range *)
|
||||||
|
let setbatesrange n =
|
||||||
|
let first_page =
|
||||||
|
let range = Cpdf.parse_pagespec_without_pdf (get_pagespec ()) in
|
||||||
|
fold_left min max_int range
|
||||||
|
in
|
||||||
|
args.bates <- n + 1 - first_page
|
||||||
|
|
||||||
let setkeepversion () =
|
let setkeepversion () =
|
||||||
args.keepversion <- true
|
args.keepversion <- true
|
||||||
|
|
||||||
|
@ -1593,6 +1607,9 @@ and specs =
|
||||||
("-bates",
|
("-bates",
|
||||||
Arg.Int setbates,
|
Arg.Int setbates,
|
||||||
" Set the base bates number");
|
" Set the base bates number");
|
||||||
|
("-bates-at-range",
|
||||||
|
Arg.Int setbatesrange,
|
||||||
|
" Set the base bates number at first page in range");
|
||||||
("-bates-pad-to",
|
("-bates-pad-to",
|
||||||
Arg.Int setbatespad,
|
Arg.Int setbatespad,
|
||||||
" Pad the bates number with leading zeroes to width");
|
" Pad the bates number with leading zeroes to width");
|
||||||
|
@ -2251,10 +2268,6 @@ let split_pdf
|
||||||
enc 0 original_filename squeeze nobble spec pdf
|
enc 0 original_filename squeeze nobble spec pdf
|
||||||
(splitinto chunksize (indx pdf_pages)) pdf_pages
|
(splitinto chunksize (indx pdf_pages)) pdf_pages
|
||||||
|
|
||||||
let get_pagespec () =
|
|
||||||
match args.inputs with
|
|
||||||
| (_, ps, _, _, _, _)::_ -> ps
|
|
||||||
| _ -> error "get_pagespec"
|
|
||||||
|
|
||||||
(* Copy a font from [frompdf] with name [fontname] on page [fontpage] to [pdf] on all pages in [range] *)
|
(* Copy a font from [frompdf] with name [fontname] on page [fontpage] to [pdf] on all pages in [range] *)
|
||||||
let copy_font frompdf fontname fontpage range pdf =
|
let copy_font frompdf fontname fontpage range pdf =
|
||||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -1,12 +1,14 @@
|
||||||
%FIXME: Document -no-embed-font and encoding switch
|
%FIXME: Document -no-embed-font and encoding switch
|
||||||
%Documents bates enhancements
|
%Documents bates enhancements
|
||||||
|
%Document -bates-at-range (must come after range given) and after -bates if
|
||||||
|
%given
|
||||||
\documentclass{book}
|
\documentclass{book}
|
||||||
\usepackage{palatino}
|
\usepackage{palatino}
|
||||||
\usepackage{microtype}
|
\usepackage{microtype}
|
||||||
\usepackage{graphics}
|
\usepackage{graphics}
|
||||||
\usepackage[plainpages=false,pdfpagelabels,pdfborder=0 0 0]{hyperref}
|
\usepackage[plainpages=false,pdfpagelabels,pdfborder=0 0 0]{hyperref}
|
||||||
\usepackage{framed}
|
\usepackage{framed}
|
||||||
\newcommand{\smallgap}{\vspace{4mm}}
|
\newcommand{\smallgap}{\bigskip}
|
||||||
\newcommand{\cpdf}{\texttt{cpdf}}
|
\newcommand{\cpdf}{\texttt{cpdf}}
|
||||||
\addtolength{\textwidth}{20mm}
|
\addtolength{\textwidth}{20mm}
|
||||||
\usepackage{makeidx}\makeindex
|
\usepackage{makeidx}\makeindex
|
||||||
|
|
Loading…
Reference in New Issue