Plumbing for -add-page-labels -labels-progress
This commit is contained in:
parent
02574b57d4
commit
08ca9bea6f
2
cpdf.ml
2
cpdf.ml
|
@ -4171,7 +4171,7 @@ let rec ranges_of_range curr prev = function
|
||||||
let page1 labels =
|
let page1 labels =
|
||||||
mem true (map (function l -> l.Pdfpagelabels.startpage = 1) labels)
|
mem true (map (function l -> l.Pdfpagelabels.startpage = 1) labels)
|
||||||
|
|
||||||
let add_page_labels pdf style prefix startval range =
|
let add_page_labels pdf progress style prefix startval range =
|
||||||
let ranges = map extremes (ranges_of_range [] [] range)
|
let ranges = map extremes (ranges_of_range [] [] range)
|
||||||
and labels = Pdfpagelabels.read pdf in
|
and labels = Pdfpagelabels.read pdf in
|
||||||
let labels =
|
let labels =
|
||||||
|
|
2
cpdf.mli
2
cpdf.mli
|
@ -405,7 +405,7 @@ val blank_document_paper : Pdfpaper.t -> int -> Pdf.t
|
||||||
|
|
||||||
(** Add page labels. *)
|
(** Add page labels. *)
|
||||||
val add_page_labels :
|
val add_page_labels :
|
||||||
Pdf.t -> Pdfpagelabels.labelstyle -> string option -> int -> int list -> unit
|
Pdf.t -> bool -> Pdfpagelabels.labelstyle -> string option -> int -> int list -> unit
|
||||||
|
|
||||||
(** {2 Miscellany} *)
|
(** {2 Miscellany} *)
|
||||||
|
|
||||||
|
|
|
@ -413,6 +413,7 @@ type args =
|
||||||
mutable labelstyle : Pdfpagelabels.labelstyle;
|
mutable labelstyle : Pdfpagelabels.labelstyle;
|
||||||
mutable labelprefix : string option;
|
mutable labelprefix : string option;
|
||||||
mutable labelstartval : int;
|
mutable labelstartval : int;
|
||||||
|
mutable labelsprogress : bool;
|
||||||
mutable squeeze : bool;
|
mutable squeeze : bool;
|
||||||
mutable original_filename : string;
|
mutable original_filename : string;
|
||||||
mutable was_encrypted : bool;
|
mutable was_encrypted : bool;
|
||||||
|
@ -508,6 +509,7 @@ let args =
|
||||||
labelstyle = Pdfpagelabels.DecimalArabic;
|
labelstyle = Pdfpagelabels.DecimalArabic;
|
||||||
labelprefix = None;
|
labelprefix = None;
|
||||||
labelstartval = 1;
|
labelstartval = 1;
|
||||||
|
labelsprogress = false;
|
||||||
squeeze = false;
|
squeeze = false;
|
||||||
original_filename = "";
|
original_filename = "";
|
||||||
was_encrypted = false;
|
was_encrypted = false;
|
||||||
|
@ -602,6 +604,7 @@ let reset_arguments () =
|
||||||
args.labelstyle <- Pdfpagelabels.DecimalArabic;
|
args.labelstyle <- Pdfpagelabels.DecimalArabic;
|
||||||
args.labelprefix <- None;
|
args.labelprefix <- None;
|
||||||
args.labelstartval <- 1;
|
args.labelstartval <- 1;
|
||||||
|
args.labelsprogress <- false;
|
||||||
args.embedfonts <- true;
|
args.embedfonts <- true;
|
||||||
args.extract_text_font_size <- None;
|
args.extract_text_font_size <- None;
|
||||||
args.padwith <- None;
|
args.padwith <- None;
|
||||||
|
@ -1382,6 +1385,9 @@ let setlabelprefix s =
|
||||||
let setlabelstartval i =
|
let setlabelstartval i =
|
||||||
args.labelstartval <- i
|
args.labelstartval <- i
|
||||||
|
|
||||||
|
let setlabelsprogress () =
|
||||||
|
args.labelsprogress <- true
|
||||||
|
|
||||||
let setcpdflin s =
|
let setcpdflin s =
|
||||||
args.cpdflin <- Some s
|
args.cpdflin <- Some s
|
||||||
|
|
||||||
|
@ -2038,6 +2044,9 @@ and specs =
|
||||||
("-label-startval",
|
("-label-startval",
|
||||||
Arg.Int setlabelstartval,
|
Arg.Int setlabelstartval,
|
||||||
" Set label start value (default 1)");
|
" Set label start value (default 1)");
|
||||||
|
("-labels-progress",
|
||||||
|
Arg.Unit setlabelsprogress,
|
||||||
|
" Label start value progresses with multiple ranges");
|
||||||
("-remove-dict-entry",
|
("-remove-dict-entry",
|
||||||
Arg.String setremovedictentry,
|
Arg.String setremovedictentry,
|
||||||
" Remove an entry from all dictionaries");
|
" Remove an entry from all dictionaries");
|
||||||
|
@ -4344,7 +4353,7 @@ let go () =
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let range = parse_pagespec pdf (get_pagespec ()) in
|
let range = parse_pagespec pdf (get_pagespec ()) in
|
||||||
Cpdf.add_page_labels
|
Cpdf.add_page_labels
|
||||||
pdf args.labelstyle args.labelprefix args.labelstartval range;
|
pdf args.labelsprogress args.labelstyle args.labelprefix args.labelstartval range;
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| Some RemovePageLabels ->
|
| Some RemovePageLabels ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
|
|
Loading…
Reference in New Issue