more
This commit is contained in:
parent
65322900ee
commit
484c30b9ab
|
@ -88,7 +88,6 @@ let parse_pagespec_allow_empty pdf spec =
|
||||||
try Cpdfpagespec.parse_pagespec pdf spec with
|
try Cpdfpagespec.parse_pagespec pdf spec with
|
||||||
Pdf.PDFError ("Page range specifies no pages") -> []
|
Pdf.PDFError ("Page range specifies no pages") -> []
|
||||||
|
|
||||||
|
|
||||||
(* Operations. *)
|
(* Operations. *)
|
||||||
type op =
|
type op =
|
||||||
| CopyFont of string
|
| CopyFont of string
|
||||||
|
@ -1778,35 +1777,27 @@ let whingemalformed () =
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
(* Drawing operations. *)
|
(* Drawing operations. *)
|
||||||
let drawops = ref []
|
let drawops = ref [("main", [])]
|
||||||
|
|
||||||
let saved_ops =
|
|
||||||
Hashtbl.create 16
|
|
||||||
|
|
||||||
let we_are_saving = ref None
|
|
||||||
|
|
||||||
let startxobj n =
|
let startxobj n =
|
||||||
we_are_saving := Some n;
|
drawops := (n, [])::!drawops
|
||||||
Hashtbl.add saved_ops n []
|
|
||||||
|
|
||||||
let xobjbbox s =
|
let xobjbbox s =
|
||||||
args.xobj_bbox <- Cpdfcoord.parse_rectangle (Pdf.empty ()) s
|
args.xobj_bbox <- Cpdfcoord.parse_rectangle (Pdf.empty ()) s
|
||||||
|
|
||||||
let addop o =
|
let addop o =
|
||||||
match !we_are_saving with
|
match !drawops with
|
||||||
| Some n ->
|
| (n, ops)::t -> drawops := (n, (o::ops))::t
|
||||||
Hashtbl.replace saved_ops n (o::Hashtbl.find saved_ops n)
|
| [] -> error "no drawops"
|
||||||
| None ->
|
|
||||||
drawops := o::!drawops
|
|
||||||
|
|
||||||
let endxobj () =
|
let endxobj () =
|
||||||
match !we_are_saving with
|
match !drawops with
|
||||||
| Some n ->
|
| (n, ops)::t ->
|
||||||
we_are_saving := None;
|
drawops := t;
|
||||||
let a, b, c, d = args.xobj_bbox in
|
let a, b, c, d = args.xobj_bbox in
|
||||||
addop (Cpdfdraw.FormXObject (a, b, c, d, n, rev (Hashtbl.find saved_ops n)))
|
addop (Cpdfdraw.FormXObject (a, b, c, d, n, rev ops))
|
||||||
| None ->
|
| [] ->
|
||||||
error "misplaced -endxobj"
|
error "too many -endxobj"
|
||||||
|
|
||||||
let tdeep = ref 0
|
let tdeep = ref 0
|
||||||
|
|
||||||
|
@ -4480,9 +4471,10 @@ let go () =
|
||||||
if !tdeep <> 0 then error "Unmatched -bt / -et" else
|
if !tdeep <> 0 then error "Unmatched -bt / -et" else
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||||
|
let ops = match !drawops with [("main", ops)] -> rev ops | _ -> error "not enough -endxobj" in
|
||||||
write_pdf
|
write_pdf
|
||||||
false
|
false
|
||||||
(Cpdfdraw.draw ~filename:args.original_filename ~bates:args.bates ~batespad:args.batespad args.fast range pdf (rev !drawops))
|
(Cpdfdraw.draw ~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 =
|
||||||
|
|
|
@ -91,7 +91,11 @@ let respush () =
|
||||||
resstack := (rescopy (res ()))::!resstack
|
resstack := (rescopy (res ()))::!resstack
|
||||||
|
|
||||||
let respop () =
|
let respop () =
|
||||||
resstack := tl !resstack
|
let n = (hd !resstack).num in
|
||||||
|
resstack := tl !resstack;
|
||||||
|
(* not necessary, since names are isolated in the xobject, but it makes
|
||||||
|
manual debugging of PDF files easier if we don't re-use numbers *)
|
||||||
|
(res ()).num <- max n (res ()).num
|
||||||
|
|
||||||
let fresh_name s =
|
let fresh_name s =
|
||||||
(res ()).num <- (res ()).num + 1;
|
(res ()).num <- (res ()).num + 1;
|
||||||
|
|
Loading…
Reference in New Issue