more
This commit is contained in:
parent
9e08ed557e
commit
ce2ff087b8
|
@ -3917,7 +3917,7 @@ let go () =
|
|||
let font =
|
||||
match args.font with StandardFont f -> f | _ -> error "text to PDF: not a standard font"
|
||||
in
|
||||
let pdf = Cpdftexttopdf.typeset ~font ~fontsize:args.fontsize text in
|
||||
let pdf = Cpdftexttopdf.typeset ~papersize:args.createpdf_pagesize ~font ~fontsize:args.fontsize text in
|
||||
write_pdf false pdf
|
||||
|
||||
(* Advise the user if a combination of command line flags makes little sense,
|
||||
|
|
|
@ -465,8 +465,9 @@ let rec ppstring_single_object pdf = function
|
|||
| x -> x
|
||||
|
||||
let preprocess_strings pdf =
|
||||
Pdf.objselfmap (ppstring_single_object pdf) pdf;
|
||||
pdf.Pdf.trailerdict <- ppstring_single_object pdf pdf.Pdf.trailerdict
|
||||
Pdf.objselfmap (ppstring_single_object pdf) pdf
|
||||
(* Skip the trailer dictionary since may mess up /ID if it happens to begin with UTF16BE BOM *)
|
||||
(*pdf.Pdf.trailerdict <- ppstring_single_object pdf pdf.Pdf.trailerdict*)
|
||||
|
||||
let json_of_pdf
|
||||
~parse_content ~no_stream_data ~decompress_streams
|
||||
|
|
|
@ -28,13 +28,16 @@ let rec of_utf8_with_newlines t =
|
|||
if c <> "" then items := Text (explode c)::!items;
|
||||
rev !items
|
||||
|
||||
(* FIXME margins, hyphenation of too-long words, efficiency *)
|
||||
let typeset ~font ~fontsize text =
|
||||
let typeset ~papersize ~font ~fontsize text =
|
||||
let pdf = Pdf.empty () in
|
||||
let margin =
|
||||
Pdfunits.convert 72. (Pdfpaper.unit papersize) (Pdfunits.PdfPoint) (Pdfpaper.width papersize) /. 15.
|
||||
in
|
||||
let f = (Pdftext.StandardFont (font, Pdftext.WinAnsiEncoding), fontsize) in
|
||||
let pages =
|
||||
Cpdftype.typeset
|
||||
20. 20. 20. 20. Pdfpaper.a4 pdf ([Cpdftype.Font f; Cpdftype.BeginDocument] @ of_utf8_with_newlines (Pdfio.string_of_bytes text))
|
||||
margin margin margin margin papersize 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
|
||||
|
|
|
@ -1 +1 @@
|
|||
val typeset : font:Pdftext.standard_font -> fontsize:float -> Pdfio.bytes -> Pdf.t
|
||||
val typeset : papersize:Pdfpaper.t -> font:Pdftext.standard_font -> fontsize:float -> Pdfio.bytes -> Pdf.t
|
||||
|
|
Loading…
Reference in New Issue