First proof of concept for Spray
This commit is contained in:
parent
7a9c0f457f
commit
08a503be76
|
@ -1982,6 +1982,9 @@ and specs =
|
||||||
("-split-max",
|
("-split-max",
|
||||||
Arg.String setsplitmax,
|
Arg.String setsplitmax,
|
||||||
" Split a file to files of a given size");
|
" Split a file to files of a given size");
|
||||||
|
("-spray",
|
||||||
|
Arg.Unit (setop Spray),
|
||||||
|
" Split a file by alternating pages");
|
||||||
("-scale-page",
|
("-scale-page",
|
||||||
Arg.String setscale,
|
Arg.String setscale,
|
||||||
" -scale-page \"sx sy\" scales by (sx, sy)");
|
" -scale-page \"sx sy\" scales by (sx, sy)");
|
||||||
|
@ -3110,7 +3113,7 @@ let stem s =
|
||||||
(neq '.') (rev (explode (Filename.basename s))))))
|
(neq '.') (rev (explode (Filename.basename s))))))
|
||||||
|
|
||||||
let fast_write_split_pdfs
|
let fast_write_split_pdfs
|
||||||
enc splitlevel original_filename sq spec main_pdf pagenums pdf_pages
|
?(names=[]) enc splitlevel original_filename sq spec main_pdf pagenums pdf_pages
|
||||||
=
|
=
|
||||||
let marks = Pdfmarks.read_bookmarks main_pdf in
|
let marks = Pdfmarks.read_bookmarks main_pdf in
|
||||||
iter2
|
iter2
|
||||||
|
@ -3118,6 +3121,7 @@ let fast_write_split_pdfs
|
||||||
let pdf = Pdfpage.pdf_of_pages main_pdf pagenums in
|
let pdf = Pdfpage.pdf_of_pages main_pdf pagenums in
|
||||||
let startpage, endpage = extremes pagenums in
|
let startpage, endpage = extremes pagenums in
|
||||||
let name =
|
let name =
|
||||||
|
if names <> [] then List.nth names (number - 1) else
|
||||||
Cpdfbookmarks.name_of_spec
|
Cpdfbookmarks.name_of_spec
|
||||||
args.encoding marks main_pdf splitlevel spec number
|
args.encoding marks main_pdf splitlevel spec number
|
||||||
(stem original_filename) startpage endpage
|
(stem original_filename) startpage endpage
|
||||||
|
@ -3763,9 +3767,11 @@ let go () =
|
||||||
| File output_spec ->
|
| File output_spec ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let enc = build_enc () in
|
let enc = build_enc () in
|
||||||
|
let names, pagenums = rev !spray_outputs, (many [1] (length !spray_outputs)) in
|
||||||
args.create_objstm <- args.preserve_objstm;
|
args.create_objstm <- args.preserve_objstm;
|
||||||
ignore pdf;
|
fast_write_split_pdfs ~names enc 0 args.original_filename args.squeeze output_spec pdf pagenums (Pdfpage.pages_of_pagetree pdf)
|
||||||
ignore enc
|
(* Build (output filename, page range) pairs *)
|
||||||
|
(* Write them *)
|
||||||
| Stdout -> error "Can't spray to standard output"
|
| Stdout -> error "Can't spray to standard output"
|
||||||
| NoOutputSpecified -> error "Spray: No output format specified"
|
| NoOutputSpecified -> error "Spray: No output format specified"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue