From dcaa04affa2adda88c7832cf2df4fe05581abd64 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 14 Dec 2021 14:07:52 +0000 Subject: [PATCH] more --- cpdftexttopdf.ml | 2 +- cpdftoc.ml | 2 +- cpdftype.ml | 6 +++++- cpdftype.mli | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cpdftexttopdf.ml b/cpdftexttopdf.ml index a5319fe..d7d0618 100644 --- a/cpdftexttopdf.ml +++ b/cpdftexttopdf.ml @@ -34,7 +34,7 @@ let typeset ~font ~fontsize text = let f = (Pdftext.StandardFont (font, Pdftext.WinAnsiEncoding), fontsize) in let pages = Cpdftype.typeset - 20. 20. 20. 20. Pdfpaper.a4 pdf ([Cpdftype.Font f] @ of_utf8_with_newlines (Pdfio.string_of_bytes text)) + 20. 20. 20. 20. Pdfpaper.a4 pdf ([Cpdftype.Font f; Cpdftype.BeginDocument] @ of_utf8_with_newlines (Pdfio.string_of_bytes text)) in let pdf, pageroot = Pdfpage.add_pagetree pages pdf in Pdfpage.add_root pageroot [] pdf diff --git a/cpdftoc.ml b/cpdftoc.ml index c7f309b..2db1dd0 100644 --- a/cpdftoc.ml +++ b/cpdftoc.ml @@ -97,7 +97,7 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark pdf = (cminx +. margin, (pmaxx -. cmaxx) +. margin, cminy +. margin, (pmaxy -. cmaxy) +. margin) in Cpdftype.typeset lm rm tm bm firstpage_papersize pdf - ([Cpdftype.Font big] @ title @ + ([Cpdftype.Font big; Cpdftype.BeginDocument] @ title @ [Cpdftype.VGlue {glen = fontsize *. 2.; gstretch = 0.}; Cpdftype.Font (f, fs)] @ flatten lines) in diff --git a/cpdftype.ml b/cpdftype.ml index 889cb10..a2c242f 100644 --- a/cpdftype.ml +++ b/cpdftype.ml @@ -21,6 +21,7 @@ type element = | Font of (Pdftext.font * float) | BeginDest of Pdfdest.t | EndDest +| BeginDocument let to_string_elt = function | Text t -> implode t @@ -31,6 +32,7 @@ let to_string_elt = function | Font _ -> "Font" | BeginDest _ -> "BeginDest" | EndDest -> "EndDest" + | BeginDocument -> "BeginDocument" let to_string es = fold_left (fun a b -> a ^ "\n" ^ b) "" (map to_string_elt es) @@ -251,7 +253,9 @@ let typeset lmargin rmargin tmargin bmargin papersize pdf i = ops := []; if s.font <> None then typeset_element (Font (unopt s.font, s.fontsize)); s.xpos <- lmargin; - s.ypos <- tmargin + s.ypos <- tmargin +. s.fontsize + | BeginDocument -> + s.ypos <- tmargin +. s.fontsize | BeginDest dest -> s.dest <- Some dest | EndDest -> diff --git a/cpdftype.mli b/cpdftype.mli index ed5c03f..00c96ba 100644 --- a/cpdftype.mli +++ b/cpdftype.mli @@ -11,6 +11,7 @@ type element = | Font of (Pdftext.font * float) | BeginDest of Pdfdest.t | EndDest +| BeginDocument type t = element list