From 502f51b6716c3b4a88d262d8c63c67d43c09d142 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sat, 8 Mar 2025 15:55:45 +0000 Subject: [PATCH] All TOC PDF/UA examples now work --- cpdfembed.ml | 2 +- cpdftoc.ml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cpdfembed.ml b/cpdfembed.ml index 8cddbbb..6922438 100644 --- a/cpdfembed.ml +++ b/cpdfembed.ml @@ -83,7 +83,7 @@ let make_fontpack_hashtable fs = (fun u -> match charcode_extractor u with | Some x -> Hashtbl.add table u (i, x) - | None -> Printf.printf "charcode_extractor could not find char in make_fontpack_hashtable\n") + | None -> Printf.printf "charcode_extractor could not find char U+%04x in make_fontpack_hashtable\n" u) subset) indexes fs; table diff --git a/cpdftoc.ml b/cpdftoc.ml index ba55796..9ed5014 100644 --- a/cpdftoc.ml +++ b/cpdftoc.ml @@ -138,6 +138,9 @@ let add_to_parent_tree pdf p = begin match lookup "/ParentTree" d with | Some (Pdf.Indirect i) -> Pdf.addobj_given_num pdf (i, newtree) + | Some (Pdf.Dictionary d) -> + let i = Pdf.addobj pdf newtree in + Pdf.replace_chain pdf ["/Root"; "/StructTreeRoot"; "/ParentTree"] (Pdf.Indirect i) | _ -> () end | _ -> ()