From 08ca9bea6feb94e382ebe9c2f014684469836916 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sat, 25 Jan 2020 15:22:45 +0800 Subject: [PATCH] Plumbing for -add-page-labels -labels-progress --- cpdf.ml | 2 +- cpdf.mli | 2 +- cpdfcommand.ml | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cpdf.ml b/cpdf.ml index a8da3c8..5deba24 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -4171,7 +4171,7 @@ let rec ranges_of_range curr prev = function let page1 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) and labels = Pdfpagelabels.read pdf in let labels = diff --git a/cpdf.mli b/cpdf.mli index e9de765..5176a02 100644 --- a/cpdf.mli +++ b/cpdf.mli @@ -405,7 +405,7 @@ val blank_document_paper : Pdfpaper.t -> int -> Pdf.t (** 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} *) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 724c97a..67afb80 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -413,6 +413,7 @@ type args = mutable labelstyle : Pdfpagelabels.labelstyle; mutable labelprefix : string option; mutable labelstartval : int; + mutable labelsprogress : bool; mutable squeeze : bool; mutable original_filename : string; mutable was_encrypted : bool; @@ -508,6 +509,7 @@ let args = labelstyle = Pdfpagelabels.DecimalArabic; labelprefix = None; labelstartval = 1; + labelsprogress = false; squeeze = false; original_filename = ""; was_encrypted = false; @@ -602,6 +604,7 @@ let reset_arguments () = args.labelstyle <- Pdfpagelabels.DecimalArabic; args.labelprefix <- None; args.labelstartval <- 1; + args.labelsprogress <- false; args.embedfonts <- true; args.extract_text_font_size <- None; args.padwith <- None; @@ -1382,6 +1385,9 @@ let setlabelprefix s = let setlabelstartval i = args.labelstartval <- i +let setlabelsprogress () = + args.labelsprogress <- true + let setcpdflin s = args.cpdflin <- Some s @@ -2038,6 +2044,9 @@ and specs = ("-label-startval", Arg.Int setlabelstartval, " Set label start value (default 1)"); + ("-labels-progress", + Arg.Unit setlabelsprogress, + " Label start value progresses with multiple ranges"); ("-remove-dict-entry", Arg.String setremovedictentry, " Remove an entry from all dictionaries"); @@ -4344,7 +4353,7 @@ let go () = let pdf = get_single_pdf args.op false in let range = parse_pagespec pdf (get_pagespec ()) in 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 | Some RemovePageLabels -> let pdf = get_single_pdf args.op false in