mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-04-15 10:48:00 +02:00
more
This commit is contained in:
parent
9e08ed557e
commit
ce2ff087b8
@ -3917,7 +3917,7 @@ let go () =
|
|||||||
let font =
|
let font =
|
||||||
match args.font with StandardFont f -> f | _ -> error "text to PDF: not a standard font"
|
match args.font with StandardFont f -> f | _ -> error "text to PDF: not a standard font"
|
||||||
in
|
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
|
write_pdf false pdf
|
||||||
|
|
||||||
(* Advise the user if a combination of command line flags makes little sense,
|
(* 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
|
| x -> x
|
||||||
|
|
||||||
let preprocess_strings pdf =
|
let preprocess_strings pdf =
|
||||||
Pdf.objselfmap (ppstring_single_object pdf) pdf;
|
Pdf.objselfmap (ppstring_single_object pdf) pdf
|
||||||
pdf.Pdf.trailerdict <- ppstring_single_object pdf pdf.Pdf.trailerdict
|
(* 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
|
let json_of_pdf
|
||||||
~parse_content ~no_stream_data ~decompress_streams
|
~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;
|
if c <> "" then items := Text (explode c)::!items;
|
||||||
rev !items
|
rev !items
|
||||||
|
|
||||||
(* FIXME margins, hyphenation of too-long words, efficiency *)
|
let typeset ~papersize ~font ~fontsize text =
|
||||||
let typeset ~font ~fontsize text =
|
|
||||||
let pdf = Pdf.empty () in
|
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 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; 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
|
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
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user