mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2024-12-11 16:35:35 +01:00
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
|
||||
write_pdf
|
||||
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) ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let filesize =
|
||||
|
28
cpdfdraw.ml
28
cpdfdraw.ml
@ -293,39 +293,37 @@ let minimum_resource_number pdf range =
|
||||
let contains_specials 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);
|
||||
let endpage = Pdfpage.endpage pdf in
|
||||
let pages = Pdfpage.pages_of_pagetree pdf in
|
||||
let str =
|
||||
let ops =
|
||||
if contains_specials drawops
|
||||
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
|
||||
let ss =
|
||||
map2
|
||||
(fun n p ->
|
||||
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))
|
||||
else "")
|
||||
then (match ops with Some x -> x | None -> ops_of_drawops pdf endpage filename bates batespad n p drawops)
|
||||
else [])
|
||||
(ilist 1 endpage)
|
||||
pages
|
||||
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 =
|
||||
map2
|
||||
(fun n p -> if not (mem n range) then p else {p with Pdfpage.resources = update_resources pdf p.Pdfpage.resources})
|
||||
map3
|
||||
(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)
|
||||
(Pdfpage.pages_of_pagetree pdf)
|
||||
ss
|
||||
in
|
||||
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 ()];
|
||||
(res ()).time <- Cpdfstrftime.current_time ();
|
||||
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
|
||||
while !chunks <> [] do
|
||||
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;
|
||||
if !chunks <> [] then begin
|
||||
let endpage = Pdfpage.endpage !pdf in
|
||||
|
@ -45,7 +45,9 @@ type drawops =
|
||||
| RenderMode of int
|
||||
| Rise of float
|
||||
|
||||
val draw : filename:string ->
|
||||
val draw : ?fast:bool ->
|
||||
?underneath:bool ->
|
||||
filename:string ->
|
||||
bates:int ->
|
||||
batespad:int option ->
|
||||
bool -> int list -> Pdf.t -> drawops list -> Pdf.t
|
||||
|
@ -15,6 +15,7 @@
|
||||
%Document -open-at-page-custom
|
||||
%Document -text-width
|
||||
%Error handling for png /jpeg loaders
|
||||
%-underneath for -draw
|
||||
\documentclass{book}
|
||||
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,
|
||||
% dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc.
|
||||
|
Loading…
Reference in New Issue
Block a user