more
This commit is contained in:
parent
5c05d80b6b
commit
51b1c8ffce
|
@ -4467,7 +4467,7 @@ let go () =
|
||||||
let ops = match !drawops with [("_MAIN", ops)] -> rev ops | _ -> error "not enough -end-xobj or -et" in
|
let ops = match !drawops with [("_MAIN", ops)] -> rev ops | _ -> error "not enough -end-xobj or -et" in
|
||||||
write_pdf
|
write_pdf
|
||||||
false
|
false
|
||||||
(Cpdfdraw.draw ~filename:args.original_filename ~bates:args.bates ~batespad:args.batespad args.fast range pdf ops)
|
(Cpdfdraw.draw ~fast:args.fast ~filename:args.original_filename ~bates:args.bates ~batespad:args.batespad args.fast range pdf ops)
|
||||||
| Some (Composition json) ->
|
| Some (Composition json) ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let filesize =
|
let filesize =
|
||||||
|
|
28
cpdfdraw.ml
28
cpdfdraw.ml
|
@ -293,39 +293,37 @@ let minimum_resource_number pdf range =
|
||||||
let contains_specials drawops =
|
let contains_specials drawops =
|
||||||
List.exists (function SpecialText _ -> true | _ -> false) drawops
|
List.exists (function SpecialText _ -> true | _ -> false) drawops
|
||||||
|
|
||||||
let draw_single ~filename ~bates ~batespad fast range pdf drawops =
|
let draw_single ~fast ~underneath ~filename ~bates ~batespad fast range pdf drawops =
|
||||||
(res ()).num <- max (res ()).num (minimum_resource_number pdf range);
|
(res ()).num <- max (res ()).num (minimum_resource_number pdf range);
|
||||||
let endpage = Pdfpage.endpage pdf in
|
let endpage = Pdfpage.endpage pdf in
|
||||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||||
let str =
|
let ops =
|
||||||
if contains_specials drawops
|
if contains_specials drawops
|
||||||
then None
|
then None
|
||||||
else Some (Pdfops.string_of_ops (ops_of_drawops pdf endpage filename bates batespad 0 (hd pages) drawops))
|
else Some (ops_of_drawops pdf endpage filename bates batespad 0 (hd pages) drawops)
|
||||||
in
|
in
|
||||||
let ss =
|
let ss =
|
||||||
map2
|
map2
|
||||||
(fun n p ->
|
(fun n p ->
|
||||||
if mem n range
|
if mem n range
|
||||||
then (match str with Some x -> x | None -> Pdfops.string_of_ops (ops_of_drawops pdf endpage filename bates batespad n p drawops))
|
then (match ops with Some x -> x | None -> ops_of_drawops pdf endpage filename bates batespad n p drawops)
|
||||||
else "")
|
else [])
|
||||||
(ilist 1 endpage)
|
(ilist 1 endpage)
|
||||||
pages
|
pages
|
||||||
in
|
in
|
||||||
let pdf = ref pdf in
|
|
||||||
iter2
|
|
||||||
(fun n s -> Printf.printf "Page %i\n%!" n; if mem n range then pdf := Cpdftweak.append_page_content s false fast [n] !pdf)
|
|
||||||
(ilist 1 endpage)
|
|
||||||
ss;
|
|
||||||
let pdf = !pdf in
|
|
||||||
let pages =
|
let pages =
|
||||||
map2
|
map3
|
||||||
(fun n p -> if not (mem n range) then p else {p with Pdfpage.resources = update_resources pdf p.Pdfpage.resources})
|
(fun n p ops ->
|
||||||
|
if not (mem n range) then p else
|
||||||
|
let page = {p with Pdfpage.resources = update_resources pdf p.Pdfpage.resources} in
|
||||||
|
(if underneath then Pdfpage.prepend_operators else Pdfpage.postpend_operators) pdf ops ~fast page)
|
||||||
(ilist 1 endpage)
|
(ilist 1 endpage)
|
||||||
(Pdfpage.pages_of_pagetree pdf)
|
(Pdfpage.pages_of_pagetree pdf)
|
||||||
|
ss
|
||||||
in
|
in
|
||||||
Pdfpage.change_pages true pdf pages
|
Pdfpage.change_pages true pdf pages
|
||||||
|
|
||||||
let draw ~filename ~bates ~batespad fast range pdf drawops =
|
let draw ?(fast=false) ?(underneath=false) ~filename ~bates ~batespad fast range pdf drawops =
|
||||||
resstack := [empty_res ()];
|
resstack := [empty_res ()];
|
||||||
(res ()).time <- Cpdfstrftime.current_time ();
|
(res ()).time <- Cpdfstrftime.current_time ();
|
||||||
let pdf = ref pdf in
|
let pdf = ref pdf in
|
||||||
|
@ -335,7 +333,7 @@ let draw ~filename ~bates ~batespad fast range pdf drawops =
|
||||||
let chunks = ref (split_around (eq NewPage) drawops) in
|
let chunks = ref (split_around (eq NewPage) drawops) in
|
||||||
while !chunks <> [] do
|
while !chunks <> [] do
|
||||||
reset_state ();
|
reset_state ();
|
||||||
if hd !chunks <> [] then pdf := draw_single ~filename ~bates ~batespad fast !range !pdf (hd !chunks);
|
if hd !chunks <> [] then pdf := draw_single ~fast ~underneath ~filename ~bates ~batespad fast !range !pdf (hd !chunks);
|
||||||
chunks := tl !chunks;
|
chunks := tl !chunks;
|
||||||
if !chunks <> [] then begin
|
if !chunks <> [] then begin
|
||||||
let endpage = Pdfpage.endpage !pdf in
|
let endpage = Pdfpage.endpage !pdf in
|
||||||
|
|
|
@ -45,7 +45,9 @@ type drawops =
|
||||||
| RenderMode of int
|
| RenderMode of int
|
||||||
| Rise of float
|
| Rise of float
|
||||||
|
|
||||||
val draw : filename:string ->
|
val draw : ?fast:bool ->
|
||||||
|
?underneath:bool ->
|
||||||
|
filename:string ->
|
||||||
bates:int ->
|
bates:int ->
|
||||||
batespad:int option ->
|
batespad:int option ->
|
||||||
bool -> int list -> Pdf.t -> drawops list -> Pdf.t
|
bool -> int list -> Pdf.t -> drawops list -> Pdf.t
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
%Document -open-at-page-custom
|
%Document -open-at-page-custom
|
||||||
%Document -text-width
|
%Document -text-width
|
||||||
%Error handling for png /jpeg loaders
|
%Error handling for png /jpeg loaders
|
||||||
|
%-underneath for -draw
|
||||||
\documentclass{book}
|
\documentclass{book}
|
||||||
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,
|
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,
|
||||||
% dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.
|
% dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.
|
||||||
|
|
Loading…
Reference in New Issue