First working Spray

This commit is contained in:
John Whitington 2023-10-30 19:10:22 +00:00
parent 08a503be76
commit e7a434f574
1 changed files with 16 additions and 8 deletions

View File

@ -3763,17 +3763,25 @@ let go () =
| NoOutputSpecified -> error "Split: No output format specified" | NoOutputSpecified -> error "Split: No output format specified"
end end
| Some Spray -> | Some Spray ->
begin match args.out with begin match args.inputs, args.out with
| File output_spec -> | (_, pagespec, _, _, _, _)::_, File output_spec ->
let pdf = get_single_pdf args.op false in let pdf = get_single_pdf args.op false in
let range = ref (parse_pagespec pdf pagespec) in
let enc = build_enc () in let enc = build_enc () in
let names, pagenums = rev !spray_outputs, (many [1] (length !spray_outputs)) in let pagenums = map ref (many [] (length !spray_outputs)) in
let n = ref 0 in
while !range <> [] do
List.nth pagenums (!n mod (length !spray_outputs)) =| hd !range;
range := tl !range;
n += 1;
done;
let names = rev !spray_outputs in
iter (fun x -> if !x = [] then error "Spray: must have at least one page for each output") pagenums;
args.create_objstm <- args.preserve_objstm; args.create_objstm <- args.preserve_objstm;
fast_write_split_pdfs ~names enc 0 args.original_filename args.squeeze output_spec pdf pagenums (Pdfpage.pages_of_pagetree pdf) fast_write_split_pdfs ~names enc 0 args.original_filename args.squeeze output_spec pdf (map rev (map (!) pagenums)) (Pdfpage.pages_of_pagetree pdf)
(* Build (output filename, page range) pairs *) | _, Stdout -> error "Can't spray to standard output"
(* Write them *) | _, NoOutputSpecified -> error "Spray: No output format specified"
| Stdout -> error "Can't spray to standard output" | _, _ -> error "Spray: no input"
| NoOutputSpecified -> error "Spray: No output format specified"
end end
| Some Presentation -> | Some Presentation ->
let pdf = get_single_pdf args.op false in let pdf = get_single_pdf args.op false in