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 f = (Pdftext.StandardFont (font, Pdftext.WinAnsiEncoding), fontsize) in
let pages = let pages =
Cpdftype.typeset 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 in
let pdf, pageroot = Pdfpage.add_pagetree pages pdf in let pdf, pageroot = Pdfpage.add_pagetree pages pdf in
Pdfpage.add_root pageroot [] pdf 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) (cminx +. margin, (pmaxx -. cmaxx) +. margin, cminy +. margin, (pmaxy -. cmaxy) +. margin)
in in
Cpdftype.typeset lm rm tm bm firstpage_papersize pdf 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.VGlue {glen = fontsize *. 2.; gstretch = 0.};
Cpdftype.Font (f, fs)] @ flatten lines) Cpdftype.Font (f, fs)] @ flatten lines)
in in

View File

@ -21,6 +21,7 @@ type element =
| Font of (Pdftext.font * float) | Font of (Pdftext.font * float)
| BeginDest of Pdfdest.t | BeginDest of Pdfdest.t
| EndDest | EndDest
| BeginDocument
let to_string_elt = function let to_string_elt = function
| Text t -> implode t | Text t -> implode t
@ -31,6 +32,7 @@ let to_string_elt = function
| Font _ -> "Font" | Font _ -> "Font"
| BeginDest _ -> "BeginDest" | BeginDest _ -> "BeginDest"
| EndDest -> "EndDest" | EndDest -> "EndDest"
| BeginDocument -> "BeginDocument"
let to_string es = fold_left (fun a b -> a ^ "\n" ^ b) "" (map to_string_elt es) 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 := []; ops := [];
if s.font <> None then typeset_element (Font (unopt s.font, s.fontsize)); if s.font <> None then typeset_element (Font (unopt s.font, s.fontsize));
s.xpos <- lmargin; s.xpos <- lmargin;
s.ypos <- tmargin s.ypos <- tmargin +. s.fontsize
| BeginDocument ->
s.ypos <- tmargin +. s.fontsize
| BeginDest dest -> | BeginDest dest ->
s.dest <- Some dest s.dest <- Some dest
| EndDest -> | EndDest ->

View File

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