MCIDs first go
This commit is contained in:
parent
7ee3d1997d
commit
9d50e3588f
|
@ -82,15 +82,15 @@ let typeset ~process_struct_tree ?subformat ?title ~papersize ~font ~fontsize te
|
||||||
raise (Pdf.PDFError "Can't use existing named font for text-to-PDF")
|
raise (Pdf.PDFError "Can't use existing named font for text-to-PDF")
|
||||||
in
|
in
|
||||||
let instrs = of_utf8_with_newlines fontpack fontsize (Pdfio.string_of_bytes text) in
|
let instrs = of_utf8_with_newlines fontpack fontsize (Pdfio.string_of_bytes text) in
|
||||||
flprint (Cpdftype.to_string instrs);
|
(*flprint (Cpdftype.to_string instrs);
|
||||||
flprint "------------------------------";
|
flprint "------------------------------";*)
|
||||||
let tagged = tag_paragraphs instrs in
|
let tagged = tag_paragraphs instrs in
|
||||||
flprint (Cpdftype.to_string tagged);
|
(*flprint (Cpdftype.to_string tagged);*)
|
||||||
let margin = Pdfunits.points (Pdfpaper.width papersize) (Pdfpaper.unit papersize) /. 15. in
|
let margin = Pdfunits.points (Pdfpaper.width papersize) (Pdfpaper.unit papersize) /. 15. in
|
||||||
let instrs =
|
let instrs =
|
||||||
if tagged = [] then [] else
|
if tagged = [] then [] else
|
||||||
let firstfont = hd (keep (function Cpdftype.Font _ -> true | _ -> false) tagged) in
|
let firstfont = hd (keep (function Cpdftype.Font _ -> true | _ -> false) tagged) in
|
||||||
[firstfont; Cpdftype.BeginDocument] @ instrs
|
[firstfont; Cpdftype.BeginDocument] @ tagged
|
||||||
in
|
in
|
||||||
let pages = Cpdftype.typeset ~process_struct_tree margin margin margin margin papersize pdf instrs in
|
let pages = Cpdftype.typeset ~process_struct_tree margin margin margin margin papersize pdf instrs in
|
||||||
let pdf, pageroot = Pdfpage.add_pagetree pages pdf in
|
let pdf, pageroot = Pdfpage.add_pagetree pages pdf in
|
||||||
|
|
|
@ -238,6 +238,8 @@ let typeset ~process_struct_tree lmargin rmargin tmargin bmargin papersize pdf i
|
||||||
let s = initial_state () in
|
let s = initial_state () in
|
||||||
s.xpos <- lmargin;
|
s.xpos <- lmargin;
|
||||||
s.ypos <- tmargin;
|
s.ypos <- tmargin;
|
||||||
|
let mcidr = ref ~-1 in
|
||||||
|
let mcid () = incr mcidr; !mcidr in
|
||||||
let ops = ref [] in
|
let ops = ref [] in
|
||||||
let fonts = ref [] in
|
let fonts = ref [] in
|
||||||
let thispagefontnums = ref [] in
|
let thispagefontnums = ref [] in
|
||||||
|
@ -300,6 +302,7 @@ let typeset ~process_struct_tree lmargin rmargin tmargin bmargin papersize pdf i
|
||||||
thispagefontnums := [];
|
thispagefontnums := [];
|
||||||
thispageannotations := [];
|
thispageannotations := [];
|
||||||
ops := [];
|
ops := [];
|
||||||
|
mcidr := -1;
|
||||||
if s.font <> None && s.fontid <> None then typeset_element (Font (unopt s.fontid, unopt s.font, s.fontsize));
|
if s.font <> None && s.fontid <> None then typeset_element (Font (unopt s.fontid, unopt s.font, s.fontsize));
|
||||||
s.xpos <- lmargin;
|
s.xpos <- lmargin;
|
||||||
s.ypos <- tmargin +. s.fontsize
|
s.ypos <- tmargin +. s.fontsize
|
||||||
|
@ -320,8 +323,8 @@ let typeset ~process_struct_tree lmargin rmargin tmargin bmargin papersize pdf i
|
||||||
thispageannotations := map annot !thisdestrectangles @ !thispageannotations;
|
thispageannotations := map annot !thisdestrectangles @ !thispageannotations;
|
||||||
s.dest <- None;
|
s.dest <- None;
|
||||||
thisdestrectangles := []
|
thisdestrectangles := []
|
||||||
| Tag s -> ()
|
| Tag s -> ops := Pdfops.Op_BDC ("/" ^ s, Pdf.Dictionary [("/MCID", Pdf.Integer (mcid ()))])::!ops
|
||||||
| EndTag -> ()
|
| EndTag -> ops := Pdfops.Op_EMC::!ops
|
||||||
in
|
in
|
||||||
iter typeset_element i;
|
iter typeset_element i;
|
||||||
write_page ();
|
write_page ();
|
||||||
|
|
Loading…
Reference in New Issue