more
This commit is contained in:
parent
3457664d3f
commit
bf024a69f2
|
@ -1,6 +1,6 @@
|
||||||
open Pdfutil
|
open Pdfutil
|
||||||
|
|
||||||
let rec of_utf8_with_newlines charcode_extractor t =
|
let rec of_utf8_with_newlines used charcode_extractor t =
|
||||||
let items = ref [] in
|
let items = ref [] in
|
||||||
let buf = ref [] in
|
let buf = ref [] in
|
||||||
let codepoints = Pdftext.codepoints_of_utf8 t in
|
let codepoints = Pdftext.codepoints_of_utf8 t in
|
||||||
|
@ -8,7 +8,7 @@ let rec of_utf8_with_newlines charcode_extractor t =
|
||||||
option_map
|
option_map
|
||||||
(fun u ->
|
(fun u ->
|
||||||
match charcode_extractor u with
|
match charcode_extractor u with
|
||||||
| Some c -> Some (char_of_int c)
|
| Some c -> Hashtbl.replace used c (); Some (char_of_int c)
|
||||||
| None -> Printf.printf "No glyph for unicode U+%04X in this font\n" u; None)
|
| None -> Printf.printf "No glyph for unicode U+%04X in this font\n" u; None)
|
||||||
cs
|
cs
|
||||||
in
|
in
|
||||||
|
@ -37,11 +37,14 @@ let typeset ?pdf ~papersize ~font ~fontsize text =
|
||||||
Pdfunits.convert
|
Pdfunits.convert
|
||||||
72. (Pdfpaper.unit papersize) (Pdfunits.PdfPoint) (Pdfpaper.width papersize) /. 15.
|
72. (Pdfpaper.unit papersize) (Pdfunits.PdfPoint) (Pdfpaper.width papersize) /. 15.
|
||||||
in
|
in
|
||||||
|
let used = null_hash () in
|
||||||
let pages =
|
let pages =
|
||||||
Cpdftype.typeset
|
Cpdftype.typeset
|
||||||
margin margin margin margin papersize pdf
|
margin margin margin margin papersize pdf
|
||||||
([Cpdftype.Font (font, fontsize); Cpdftype.BeginDocument] @
|
([Cpdftype.Font (font, fontsize); Cpdftype.BeginDocument] @
|
||||||
of_utf8_with_newlines charcode_extractor (Pdfio.string_of_bytes text))
|
of_utf8_with_newlines used charcode_extractor (Pdfio.string_of_bytes text))
|
||||||
in
|
in
|
||||||
|
let codes = map fst (list_of_hashtbl used) in
|
||||||
|
Printf.printf "%i codes used\n" (length codes);
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue