From 1fbda88348ef82401347fd91abc8b28979f37520 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 13 Jun 2023 20:23:59 +0100 Subject: [PATCH] closer..closer.... --- cpdftexttopdf.ml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cpdftexttopdf.ml b/cpdftexttopdf.ml index 7d85eba..64c9d33 100644 --- a/cpdftexttopdf.ml +++ b/cpdftexttopdf.ml @@ -2,7 +2,7 @@ open Pdfutil let rec of_utf8_with_newlines fontpack fontsize t = let items = ref [] in - let currfont = ref 0 in + let currfont = ref ~-1 in let codepoints = Pdftext.codepoints_of_utf8 t in let currtext = ref [] in let process_codepoints cs = @@ -10,7 +10,7 @@ let rec of_utf8_with_newlines fontpack fontsize t = (fun u -> match Cpdfembed.get_char fontpack u with | Some (c, n, f) -> - (*Printf.printf "Charcode %i, font number %i\n" c n;*) + Printf.printf "Charcode %i, font number %i\n" c n; begin if n <> !currfont then begin if !currtext <> [] then items := Cpdftype.Text (rev !currtext)::!items; @@ -55,10 +55,7 @@ let typeset ~papersize ~font ~fontsize text = raise (Pdf.PDFError "Can't use existing named font for text-to-PDF") in let instrs = of_utf8_with_newlines fontpack fontsize (Pdfio.string_of_bytes text) in - let margin = - Pdfunits.points (Pdfpaper.width papersize) (Pdfpaper.unit papersize) /. 15. - in - Printf.printf "**** made instructions for page\n"; + let margin = Pdfunits.points (Pdfpaper.width papersize) (Pdfpaper.unit papersize) /. 15. in let firstfont = hd (keep (function Cpdftype.Font _ -> true | _ -> false) instrs) in let instrs = [firstfont; Cpdftype.BeginDocument] @ instrs in let pages = Cpdftype.typeset margin margin margin margin papersize pdf instrs in