Towards structure trees
This commit is contained in:
parent
c70e960c66
commit
5861665322
18
cpdfdraw.ml
18
cpdfdraw.ml
|
@ -459,10 +459,8 @@ let make_structure_tree pdf items =
|
||||||
(* Process the items, making the st list tree data structure *)
|
(* Process the items, making the st list tree data structure *)
|
||||||
let process = function
|
let process = function
|
||||||
| StDataMCID (n, mcid) ->
|
| StDataMCID (n, mcid) ->
|
||||||
Printf.printf "Looking for page %i\n" !pagenum;
|
|
||||||
items_out =| StItem {kind = n; pageobjnum = unopt (lookup !pagenum pageobjnums); children = [StMCID mcid]}
|
items_out =| StItem {kind = n; pageobjnum = unopt (lookup !pagenum pageobjnums); children = [StMCID mcid]}
|
||||||
| StDataPage n ->
|
| StDataPage n ->
|
||||||
Printf.printf "Setting page number to %i\n" n;
|
|
||||||
pagenum := n
|
pagenum := n
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
in
|
in
|
||||||
|
@ -473,28 +471,28 @@ let make_structure_tree pdf items =
|
||||||
the root and its /K. For now, we just have a root which contains everything
|
the root and its /K. For now, we just have a root which contains everything
|
||||||
else on one level. Later we will use StDataBeginTree / StDataEndTree to make
|
else on one level. Later we will use StDataBeginTree / StDataEndTree to make
|
||||||
more tree stuff. *)
|
more tree stuff. *)
|
||||||
|
|
||||||
(* Add the parent tree and parent pointers to the structure tree. *)
|
|
||||||
let add_parent_tree pdf =
|
|
||||||
()
|
|
||||||
|
|
||||||
let write_structure_tree pdf st =
|
let write_structure_tree pdf st =
|
||||||
|
let parentmap = ref [] in
|
||||||
let items =
|
let items =
|
||||||
map
|
map
|
||||||
(function StItem {kind; pageobjnum; children} ->
|
(function StItem {kind; pageobjnum; children} ->
|
||||||
Pdf.Dictionary [("/S", Pdf.Name kind);
|
Pdf.Dictionary [("/S", Pdf.Name kind);
|
||||||
("/P", Pdf.Indirect pageobjnum);
|
("/P", Pdf.Indirect pageobjnum);
|
||||||
("/K", Pdf.Array (map (function StMCID x -> Pdf.Integer x | _ -> assert false) children))]
|
("/K", Pdf.Array (map (function StMCID x ->
|
||||||
|
let n = Pdf.addobj pdf (Pdf.Integer x) in
|
||||||
|
parentmap =| (string_of_int x, Pdf.Indirect n);
|
||||||
|
Pdf.Indirect (Pdf.addobj pdf (Pdf.Integer x))
|
||||||
|
| _ -> assert false) children))]
|
||||||
| _ -> assert false
|
| _ -> assert false
|
||||||
)
|
)
|
||||||
st
|
st
|
||||||
in
|
in
|
||||||
let st =
|
let st =
|
||||||
Pdf.Dictionary [("/Type", Pdf.Name "/StructTreeRoot");
|
Pdf.Dictionary [("/Type", Pdf.Name "/StructTreeRoot");
|
||||||
|
("/ParentTree", Pdf.Indirect (Pdf.addobj pdf (Pdftree.build_name_tree true pdf !parentmap)));
|
||||||
("/K", Pdf.Array items)]
|
("/K", Pdf.Array items)]
|
||||||
in
|
in
|
||||||
Pdf.replace_chain pdf ["/Root"] ("/StructTreeRoot", st);
|
Pdf.replace_chain pdf ["/Root"] ("/StructTreeRoot", st)
|
||||||
add_parent_tree pdf
|
|
||||||
|
|
||||||
let draw ~struct_tree ~fast ~underneath ~filename ~bates ~batespad range pdf drawops =
|
let draw ~struct_tree ~fast ~underneath ~filename ~bates ~batespad range pdf drawops =
|
||||||
(*Printf.printf "%s\n" (string_of_drawops drawops);*)
|
(*Printf.printf "%s\n" (string_of_drawops drawops);*)
|
||||||
|
|
Loading…
Reference in New Issue