This commit is contained in:
John Whitington 2021-12-14 14:07:52 +00:00
parent ec086a1642
commit dcaa04affa
4 changed files with 8 additions and 3 deletions

View File

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

View File

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

View File

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

View File

@ -11,6 +11,7 @@ type element =
| Font of (Pdftext.font * float)
| BeginDest of Pdfdest.t
| EndDest
| BeginDocument
type t = element list