closer..closer....

This commit is contained in:
John Whitington 2023-06-13 20:23:59 +01:00
parent 3a295f99f2
commit 1fbda88348
1 changed files with 3 additions and 6 deletions

View File

@ -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