From 10fc61f98a29498568285739f151124fdfaef9e0 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Mon, 6 Dec 2021 15:33:18 -0800 Subject: [PATCH] more --- cpdfcommand.ml | 4 +++- cpdftype.ml | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index ed9eda6..3323f06 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -2995,7 +2995,9 @@ let typeset_table_of_contents ~font pdf = in [Cpdftype.BeginDest mark.Pdfmarks.target; Cpdftype.HGlue {Cpdftype.glen = float mark.Pdfmarks.level *. args.fontsize *. 2.; Cpdftype.gstretch = 0.}; - Cpdftype.Text (explode (of_pdfdocencoding f mark.Pdfmarks.text ^ " " ^ of_pdfdocencoding f label)); + Cpdftype.Text (explode (of_pdfdocencoding f mark.Pdfmarks.text)); + Cpdftype.HGlue {Cpdftype.glen = 100.; Cpdftype.gstretch = 0.}; + Cpdftype.Text (explode (of_pdfdocencoding f label)); (*Cpdftype.Text [' ']; Cpdftype.Text (explode (of_pdfdocencoding f label));*) Cpdftype.EndDest; diff --git a/cpdftype.ml b/cpdftype.ml index 5eec7dd..3c574d5 100644 --- a/cpdftype.ml +++ b/cpdftype.ml @@ -57,7 +57,8 @@ let font_widths f fontsize = 256 (fun x -> fontsize - *. float_of_int (Pdfstandard14.textwidth false Pdftext.WinAnsiEncoding stdfont (string_of_char (char_of_int x))) + *. float_of_int + (Pdfstandard14.textwidth false Pdftext.WinAnsiEncoding stdfont (string_of_char (char_of_int x))) /. 1000.) let width_of_string ws s = @@ -174,7 +175,6 @@ let make_annotations annots = dictionaries. New page only creates a page when that page has content. *) let typeset lmargin rmargin tmargin bmargin papersize pdf i = - Printf.printf "l = %f, r = %f, b = %f, t = %f\n" lmargin rmargin tmargin bmargin; let debug = false in if debug then (print_endline "***input:\n\n"; print_endline (to_string i)); let i = layout lmargin rmargin papersize i in @@ -214,9 +214,11 @@ let typeset lmargin rmargin tmargin bmargin papersize pdf i = ::!ops; (* If a destination, add the rectangle to the pile of rectangles for this annotation. *) if s.dest <> None then - thisdestrectangles := + begin let minx, miny = s.xpos, height -. s.ypos in - (minx, miny, minx +. width_of_string s.width_table cps, miny +. s.fontsize)::!thisdestrectangles + thisdestrectangles := (minx, miny, minx +. width_of_string s.width_table cps, miny +. s.fontsize)::!thisdestrectangles + end; + s.xpos <- s.xpos +. width_of_string s.width_table cps | Font (f, fontsize) -> let name, objnum = match List.assoc_opt f !fonts with