Make annotations indirect

This commit is contained in:
John Whitington 2023-07-19 14:21:25 +01:00
parent 64e2eaa9b7
commit 3c8083ecb6

View File

@ -172,14 +172,13 @@ let make_resources fontobjnums =
Pdf.Dictionary Pdf.Dictionary
[("/Font", Pdf.Dictionary (map (fun fo -> ("/F" ^ string_of_int fo, Pdf.Indirect fo)) (setify fontobjnums)))] [("/Font", Pdf.Dictionary (map (fun fo -> ("/F" ^ string_of_int fo, Pdf.Indirect fo)) (setify fontobjnums)))]
let make_annotations annots = let make_annotations pdf annots =
if annots = [] then Pdf.Dictionary [] else if annots = [] then Pdf.Dictionary [] else
Pdf.Dictionary ["/Annots", Pdf.Array annots] Pdf.Dictionary ["/Annots", Pdf.Array (map (function a -> Pdf.Indirect (Pdf.addobj pdf a)) annots)]
(* At this stage, just Font and Text and HGlue 0. and VGlue 0. and Newline and (* At this stage, just Font and Text and HGlue 0. and VGlue 0. and Newline and
NewPage elements. Split on NewPages, typeset each page, add font NewPage elements. Split on NewPages, typeset each page, add font
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 =
let debug = false in let debug = false in
if debug then (print_endline "***input:\n\n"; print_endline (to_string i)); if debug then (print_endline "***input:\n\n"; print_endline (to_string i));
@ -204,7 +203,7 @@ let typeset lmargin rmargin tmargin bmargin papersize pdf i =
Pdfpage.mediabox = Pdfpage.rectangle_of_paper papersize; Pdfpage.mediabox = Pdfpage.rectangle_of_paper papersize;
Pdfpage.resources = make_resources !thispagefontnums; Pdfpage.resources = make_resources !thispagefontnums;
Pdfpage.rotate = Pdfpage.Rotate0; Pdfpage.rotate = Pdfpage.Rotate0;
Pdfpage.rest = make_annotations !thispageannotations} Pdfpage.rest = make_annotations pdf !thispageannotations}
in in
pages := page :: !pages pages := page :: !pages
in in