This commit is contained in:
John Whitington 2023-05-11 15:55:48 +01:00
parent b5ad08f196
commit 5f83c581f7
2 changed files with 7 additions and 11 deletions

View File

@ -1893,9 +1893,7 @@ let closepath () =
addop Cpdfdraw.ClosePath addop Cpdfdraw.ClosePath
let setthickness s = let setthickness s =
try try addop (Cpdfdraw.SetLineThickness (float_of_string s)) with
addop (Cpdfdraw.SetLineThickness (float_of_string s))
with
_ -> error "Thickness must be a number" _ -> error "Thickness must be a number"
let setcap s = let setcap s =
@ -1919,9 +1917,7 @@ let setjoin s =
addop (Cpdfdraw.SetLineJoin num) addop (Cpdfdraw.SetLineJoin num)
let setmiter s = let setmiter s =
try try addop (Cpdfdraw.SetMiterLimit (float_of_string s)) with
addop (Cpdfdraw.SetMiterLimit (float_of_string s))
with
_ -> error "Miter limit must be a number" _ -> error "Miter limit must be a number"
let setdash s = let setdash s =
@ -2089,7 +2085,6 @@ let addspecialtext s =
let addleading f = let addleading f =
addop (Cpdfdraw.Leading f) addop (Cpdfdraw.Leading f)
let addcharspace f = let addcharspace f =
addop (Cpdfdraw.CharSpace f) addop (Cpdfdraw.CharSpace f)

View File

@ -1,4 +1,5 @@
open Pdfutil open Pdfutil
open Cpdferror
type colspec = type colspec =
NoCol NoCol
@ -93,7 +94,7 @@ let resstack =
ref [empty_res ()] ref [empty_res ()]
let res () = let res () =
hd !resstack try hd !resstack with _ -> error "graphics stack empty"
let rescopy r = let rescopy r =
{r with {r with
@ -106,7 +107,7 @@ let respush () =
resstack := (rescopy (res ()))::!resstack resstack := (rescopy (res ()))::!resstack
let respop () = let respop () =
let n = (hd !resstack).num in let n = (res ()).num in
resstack := tl !resstack; resstack := tl !resstack;
(* not necessary, since names are isolated in the xobject, but it makes (* 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 *) manual debugging of PDF files easier if we don't re-use numbers *)
@ -202,11 +203,11 @@ let rec ops_of_drawop pdf endpage filename bates batespad num page = function
create_form_xobject a b c d pdf endpage filename bates batespad num page n ops; create_form_xobject a b c d pdf endpage filename bates batespad num page n ops;
[] []
| Use n -> | Use n ->
let pdfname = try fst (Hashtbl.find (res ()).form_xobjects n) with _ -> Cpdferror.error ("Form XObject not found: " ^ n) in let pdfname = try fst (Hashtbl.find (res ()).form_xobjects n) with _ -> error ("Form XObject not found: " ^ n) in
(res ()).page_names <- pdfname::(res ()).page_names; (res ()).page_names <- pdfname::(res ()).page_names;
[Pdfops.Op_Do pdfname] [Pdfops.Op_Do pdfname]
| Image s -> | Image s ->
let pdfname = try fst (Hashtbl.find (res ()).images s) with _ -> Cpdferror.error ("Image not found: " ^ s) in let pdfname = try fst (Hashtbl.find (res ()).images s) with _ -> error ("Image not found: " ^ s) in
(res ()).page_names <- pdfname::(res ()).page_names; (res ()).page_names <- pdfname::(res ()).page_names;
[Pdfops.Op_Do pdfname] [Pdfops.Op_Do pdfname]
| ImageXObject (s, obj) -> | ImageXObject (s, obj) ->