This commit is contained in:
John Whitington 2022-09-21 15:30:28 +01:00
parent d030bc7e74
commit c08b0351ca
3 changed files with 6 additions and 5 deletions

View File

@ -3998,15 +3998,16 @@ let go () =
write_pdf false pdf
| Some (Typeset filename) ->
let text = Pdfio.bytes_of_input_channel (open_in filename) in
let pdf = Pdf.empty () in
let font =
match args.font with
| StandardFont f -> Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding)
| FontToEmbed (fontfile, encoding) ->
Cpdfembed.embed_truetype (Pdf.empty ()) ~fontfile ~fontname:args.fontname ~codepoints:[] ~encoding
Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~codepoints:[] ~encoding
| _ -> error "text to PDF: not a standard or embedded font"
in
let pdf =
Cpdftexttopdf.typeset ~papersize:args.createpdf_pagesize ~font ~fontsize:args.fontsize text
Cpdftexttopdf.typeset ~pdf:pdf ~papersize:args.createpdf_pagesize ~font ~fontsize:args.fontsize text
in
write_pdf false pdf

View File

@ -28,9 +28,9 @@ let rec of_utf8_with_newlines charcode_extractor t =
if c <> [] then items := Text (charcodes_of_codepoints c)::!items;
rev !items
let typeset ~papersize ~font ~fontsize text =
let typeset ?pdf ~papersize ~font ~fontsize text =
let charcode_extractor = Pdftext.charcode_extractor_of_font_real font in
let pdf = Pdf.empty () in
let pdf = match pdf with None -> Pdf.empty () | Some pdf -> pdf in
let margin =
Pdfunits.convert
72. (Pdfpaper.unit papersize) (Pdfunits.PdfPoint) (Pdfpaper.width papersize) /. 15.

View File

@ -1,4 +1,4 @@
(** Text to PDF *)
(** Typeset a text file as a PDF. *)
val typeset : papersize:Pdfpaper.t -> font:Pdftext.font -> fontsize:float -> Pdfio.bytes -> Pdf.t
val typeset : ?pdf:Pdf.t -> papersize:Pdfpaper.t -> font:Pdftext.font -> fontsize:float -> Pdfio.bytes -> Pdf.t