From 5f83c581f7161c143afd8a6d0ace61580c5d5075 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 11 May 2023 15:55:48 +0100 Subject: [PATCH] more --- cpdfcommand.ml | 9 ++------- cpdfdraw.ml | 9 +++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 4024b99..64af924 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1893,9 +1893,7 @@ let closepath () = addop Cpdfdraw.ClosePath let setthickness s = - try - addop (Cpdfdraw.SetLineThickness (float_of_string s)) - with + try addop (Cpdfdraw.SetLineThickness (float_of_string s)) with _ -> error "Thickness must be a number" let setcap s = @@ -1919,9 +1917,7 @@ let setjoin s = addop (Cpdfdraw.SetLineJoin num) let setmiter s = - try - addop (Cpdfdraw.SetMiterLimit (float_of_string s)) - with + try addop (Cpdfdraw.SetMiterLimit (float_of_string s)) with _ -> error "Miter limit must be a number" let setdash s = @@ -2089,7 +2085,6 @@ let addspecialtext s = let addleading f = addop (Cpdfdraw.Leading f) - let addcharspace f = addop (Cpdfdraw.CharSpace f) diff --git a/cpdfdraw.ml b/cpdfdraw.ml index 9ceee21..d39cc87 100644 --- a/cpdfdraw.ml +++ b/cpdfdraw.ml @@ -1,4 +1,5 @@ open Pdfutil +open Cpdferror type colspec = NoCol @@ -93,7 +94,7 @@ let resstack = ref [empty_res ()] let res () = - hd !resstack + try hd !resstack with _ -> error "graphics stack empty" let rescopy r = {r with @@ -106,7 +107,7 @@ let respush () = resstack := (rescopy (res ()))::!resstack let respop () = - let n = (hd !resstack).num in + let n = (res ()).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 *) @@ -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; [] | 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; [Pdfops.Op_Do pdfname] | 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; [Pdfops.Op_Do pdfname] | ImageXObject (s, obj) ->