mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-05-29 10:24:38 +02:00
/Document for PDF/UA-2 in TOC
This commit is contained in:
parent
59eb6a3573
commit
960b444e6e
35
cpdftoc.ml
35
cpdftoc.ml
@ -275,10 +275,25 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark ~dotleader ~proce
|
|||||||
in
|
in
|
||||||
if process_struct_tree then
|
if process_struct_tree then
|
||||||
begin
|
begin
|
||||||
|
(* Get indirect of top-level /Document *)
|
||||||
|
let top_level_document =
|
||||||
|
match subformat with Some Cpdfua.PDFUA2 ->
|
||||||
|
begin match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/StructTreeRoot"] with
|
||||||
|
| Some d ->
|
||||||
|
begin match Pdf.lookup_immediate "/K" d with
|
||||||
|
| Some (Pdf.Indirect i) -> i
|
||||||
|
| Some (Pdf.Array [Pdf.Indirect i]) -> i
|
||||||
|
| _ -> 0
|
||||||
|
end
|
||||||
|
| _ -> 0
|
||||||
|
end
|
||||||
|
| _ -> 0
|
||||||
|
in
|
||||||
let struct_tree_root =
|
let struct_tree_root =
|
||||||
match Pdf.lookup_immediate "/StructTreeRoot" (Pdf.lookup_obj pdf pdf.Pdf.root) with
|
if top_level_document > 0 then top_level_document else
|
||||||
| Some (Pdf.Indirect i) -> i
|
match Pdf.lookup_immediate "/StructTreeRoot" (Pdf.lookup_obj pdf pdf.Pdf.root) with
|
||||||
| _ -> 0 (* Will never happen, because we ran ensure_minimal_struct_tree *)
|
| Some (Pdf.Indirect i) -> i
|
||||||
|
| _ -> 0 (* Will never happen, because we ran ensure_minimal_struct_tree *)
|
||||||
in
|
in
|
||||||
let p_struct_elem_first_page =
|
let p_struct_elem_first_page =
|
||||||
Pdf.addobj pdf
|
Pdf.addobj pdf
|
||||||
@ -355,15 +370,9 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark ~dotleader ~proce
|
|||||||
(* FIXME Move this code up, and return i so we can put the proper /P parent entries in our structure elements. They should point to /Document now not the /StructTreeRoot. *)
|
(* FIXME Move this code up, and return i so we can put the proper /P parent entries in our structure elements. They should point to /Document now not the /StructTreeRoot. *)
|
||||||
begin match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/StructTreeRoot"] with
|
begin match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/StructTreeRoot"] with
|
||||||
| Some d ->
|
| Some d ->
|
||||||
(* Get indirect of top-level /Document *)
|
|
||||||
let i =
|
if top_level_document = 0 then () else
|
||||||
match Pdf.lookup_immediate "/K" d with
|
let obj = Pdf.lookup_obj pdf top_level_document in
|
||||||
| Some (Pdf.Indirect i) -> Some i
|
|
||||||
| Some (Pdf.Array [Pdf.Indirect i]) -> Some i
|
|
||||||
| _ -> None
|
|
||||||
in
|
|
||||||
if i = None then () else
|
|
||||||
let obj = Pdf.lookup_obj pdf (unopt i) in
|
|
||||||
let obj' =
|
let obj' =
|
||||||
let k' =
|
let k' =
|
||||||
match Pdf.lookup_direct pdf "/K" obj with
|
match Pdf.lookup_direct pdf "/K" obj with
|
||||||
@ -373,7 +382,7 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark ~dotleader ~proce
|
|||||||
in
|
in
|
||||||
Pdf.add_dict_entry obj "/K" k'
|
Pdf.add_dict_entry obj "/K" k'
|
||||||
in
|
in
|
||||||
Pdf.addobj_given_num pdf (unopt i, obj')
|
Pdf.addobj_given_num pdf (top_level_document, obj')
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user