more
This commit is contained in:
parent
e5074c20a3
commit
5a513eeb61
20
cpdftype.ml
20
cpdftype.ml
|
@ -80,7 +80,13 @@ let split_text space_left widths t =
|
||||||
let word, rest = cleavewhile (neq ' ') !chars in
|
let word, rest = cleavewhile (neq ' ') !chars in
|
||||||
let w = width_of_string widths word in
|
let w = width_of_string widths word in
|
||||||
if !words = [] || w < !space_left
|
if !words = [] || w < !space_left
|
||||||
then (words := (word @ [' '])::!words; space_left := !space_left -. w -. width_of_string widths [' '])
|
then
|
||||||
|
let is_last_word = rest = [] in
|
||||||
|
let new_word = if is_last_word then word else word @ [' '] in
|
||||||
|
begin
|
||||||
|
words := new_word::!words;
|
||||||
|
space_left := !space_left -. w -. (if is_last_word then 0. else width_of_string widths [' '])
|
||||||
|
end
|
||||||
else raise Exit;
|
else raise Exit;
|
||||||
chars := if rest = [] then [] else tl rest;
|
chars := if rest = [] then [] else tl rest;
|
||||||
done;
|
done;
|
||||||
|
@ -165,14 +171,12 @@ let make_annotations annots =
|
||||||
dictionaries. New page only
|
dictionaries. New page only
|
||||||
creates a page when that page has content. *)
|
creates a page when that page has content. *)
|
||||||
let typeset lmargin rmargin tmargin bmargin papersize pdf i =
|
let typeset lmargin rmargin tmargin bmargin papersize pdf i =
|
||||||
print_endline "***input:\n\n";
|
let debug = false in
|
||||||
print_endline (to_string i);
|
if debug then (print_endline "***input:\n\n"; print_endline (to_string i));
|
||||||
let i = layout lmargin rmargin papersize i in
|
let i = layout lmargin rmargin papersize i in
|
||||||
print_endline "***after layout:\n\n";
|
if debug then (print_endline "***after layout:\n\n"; print_endline (to_string i));
|
||||||
print_endline (to_string i);
|
|
||||||
let i = paginate tmargin bmargin papersize i in
|
let i = paginate tmargin bmargin papersize i in
|
||||||
print_endline "***after pagination:\n\n";
|
if debug then (print_endline "***after pagination:\n\n"; print_endline (to_string i));
|
||||||
print_endline (to_string i);
|
|
||||||
let height = Pdfunits.convert 72. (Pdfpaper.unit papersize) Pdfunits.PdfPoint (Pdfpaper.height papersize) in
|
let height = Pdfunits.convert 72. (Pdfpaper.unit papersize) Pdfunits.PdfPoint (Pdfpaper.height papersize) in
|
||||||
let s = initial_state () in
|
let s = initial_state () in
|
||||||
s.xpos <- lmargin;
|
s.xpos <- lmargin;
|
||||||
|
@ -247,7 +251,7 @@ let typeset lmargin rmargin tmargin bmargin papersize pdf i =
|
||||||
Pdf.Dictionary
|
Pdf.Dictionary
|
||||||
[("/Type", Pdf.Name "/Annot");
|
[("/Type", Pdf.Name "/Annot");
|
||||||
("/Subtype", Pdf.Name "/Link");
|
("/Subtype", Pdf.Name "/Link");
|
||||||
("/Border", Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real 1.]);
|
("/Border", Pdf.Array [Pdf.Real 0.; Pdf.Real 0.; Pdf.Real 0.]);
|
||||||
("/Rect", Pdf.Array [Pdf.Real minx; Pdf.Real miny; Pdf.Real maxx; Pdf.Real maxy]);
|
("/Rect", Pdf.Array [Pdf.Real minx; Pdf.Real miny; Pdf.Real maxx; Pdf.Real maxy]);
|
||||||
("/Dest", Pdfdest.pdfobject_of_destination (unopt s.dest))]
|
("/Dest", Pdfdest.pdfobject_of_destination (unopt s.dest))]
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in New Issue