This commit is contained in:
John Whitington 2024-12-03 19:10:31 +00:00
parent 95811e3e38
commit c1013ea7fe
2 changed files with 10 additions and 6 deletions

View File

@ -20,6 +20,7 @@ o Allow JSON / PDF syntax in dict processing and object exploration
o Show %Bookmark text when stamping text o Show %Bookmark text when stamping text
o Change units for -info[-json] and -page-info[-json] o Change units for -info[-json] and -page-info[-json]
o Optionally add dot leaders to tables of content o Optionally add dot leaders to tables of content
o Add -collate-n to extend -collate to multiple pages at once
Fixes: Fixes:

View File

@ -531,7 +531,7 @@ type args =
mutable ocgrenameto : string; mutable ocgrenameto : string;
mutable dedup : bool; mutable dedup : bool;
mutable dedup_per_page : bool; mutable dedup_per_page : bool;
mutable collate : bool; mutable collate : int;
mutable impose_columns : bool; mutable impose_columns : bool;
mutable impose_rtl : bool; mutable impose_rtl : bool;
mutable impose_btt : bool; mutable impose_btt : bool;
@ -681,7 +681,7 @@ let args =
ocgrenameto = ""; ocgrenameto = "";
dedup = false; dedup = false;
dedup_per_page = false; dedup_per_page = false;
collate = false; collate = 0;
impose_columns = false; impose_columns = false;
impose_rtl = false; impose_rtl = false;
impose_btt = false; impose_btt = false;
@ -819,7 +819,7 @@ let reset_arguments () =
args.ocgrenameto <- ""; args.ocgrenameto <- "";
args.dedup <- false; args.dedup <- false;
args.dedup_per_page <- false; args.dedup_per_page <- false;
args.collate <- false; args.collate <- 0;
args.impose_columns <- false; args.impose_columns <- false;
args.impose_rtl <- false; args.impose_rtl <- false;
args.impose_btt <- false; args.impose_btt <- false;
@ -2064,8 +2064,11 @@ let specs =
Arg.String setrange, Arg.String setrange,
" Explicitly add a range"); " Explicitly add a range");
("-collate", ("-collate",
Arg.Unit (fun () -> args.collate <- true), Arg.Unit (fun () -> args.collate <- 1),
" Collate ranges when merging"); " Collate ranges when merging");
("-collate-n",
Arg.Int (fun n -> args.collate <- n),
" Collate ranges in multiples when merging");
("-revision", ("-revision",
Arg.Int setrevision, Arg.Int setrevision,
""); "");
@ -3576,7 +3579,7 @@ let json_to_output json = function
output_string f (Cpdfyojson.Safe.pretty_to_string json); output_string f (Cpdfyojson.Safe.pretty_to_string json);
close_out f close_out f
let collate (names, pdfs, ranges) = let collate n (names, pdfs, ranges) =
let ois = map ref (combine3 names pdfs ranges) in let ois = map ref (combine3 names pdfs ranges) in
let nis = ref [] in let nis = ref [] in
while flatten (map (fun {contents = (_, _, r)} -> r) ois) <> [] do while flatten (map (fun {contents = (_, _, r)} -> r) ois) <> [] do
@ -3874,7 +3877,7 @@ let go () =
(* At this point, we have the information for collation. *) (* At this point, we have the information for collation. *)
let names = map string_of_input_kind names in let names = map string_of_input_kind names in
let names, pdfs, rangenums = let names, pdfs, rangenums =
(if args.collate then collate else Fun.id) (names, pdfs, rangenums) (if args.collate > 0 then collate args.collate else Fun.id) (names, pdfs, rangenums)
in in
let outpdf = let outpdf =
Pdfmerge.merge_pdfs Pdfmerge.merge_pdfs