From c08b0351cab8950122e7232445078dbbf0b2df1c Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 21 Sep 2022 15:30:28 +0100 Subject: [PATCH] more --- cpdfcommand.ml | 5 +++-- cpdftexttopdf.ml | 4 ++-- cpdftexttopdf.mli | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 9336edf..2661f0a 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -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 diff --git a/cpdftexttopdf.ml b/cpdftexttopdf.ml index 34aefba..c47db8c 100644 --- a/cpdftexttopdf.ml +++ b/cpdftexttopdf.ml @@ -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. diff --git a/cpdftexttopdf.mli b/cpdftexttopdf.mli index 31c047d..4522929 100644 --- a/cpdftexttopdf.mli +++ b/cpdftexttopdf.mli @@ -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