mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
Correct MCID, tweak StructElem
This commit is contained in:
14
cpdftoc.ml
14
cpdftoc.ml
@ -167,8 +167,11 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark ~dotleader ~proce
|
||||
then make_dots space fontpack fontsize
|
||||
else [Cpdftype.HGlue space]
|
||||
in
|
||||
[Cpdftype.Tag ("Link", 0); Cpdftype.BeginDest (mark.Pdfmarks.target, Some mark.Pdfmarks.text); Cpdftype.HGlue indent] @ textruns @ leader @ labelruns
|
||||
@ [Cpdftype.EndDest; Cpdftype.EndTag; Cpdftype.NewLine])
|
||||
[Cpdftype.BeginDest (mark.Pdfmarks.target, Some mark.Pdfmarks.text); Cpdftype.HGlue indent]
|
||||
@ [Cpdftype.Tag ("Link", 0)] @ textruns @ [Cpdftype.EndTag]
|
||||
@ leader
|
||||
@ [Cpdftype.Tag ("Link", 0)] @ labelruns @ [Cpdftype.EndTag]
|
||||
@ [Cpdftype.EndDest; Cpdftype.NewLine])
|
||||
(Pdfmarks.read_bookmarks pdf)
|
||||
in
|
||||
let toc_pages, toc_tags =
|
||||
@ -229,7 +232,7 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark ~dotleader ~proce
|
||||
paras spanning multiple pages). *)
|
||||
iter (fun x -> Printf.printf "PAGE\n"; iter (fun (_, i) -> Printf.printf "Paragraph number %i\n" i) x) toc_tags;
|
||||
let p_struct_elem_first_page =
|
||||
Pdf.addobj pdf (Pdf.Dictionary [("/Type", Pdf.Name "/StructElem"); ("/S", Pdf.Name "/P")])
|
||||
Pdf.addobj pdf (Pdf.Dictionary [("/S", Pdf.Name "/P")])
|
||||
in
|
||||
let mcid = ref 1 in
|
||||
let link_struct_elems_for_each_page =
|
||||
@ -244,10 +247,9 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark ~dotleader ~proce
|
||||
let r = map
|
||||
(fun annot_i ->
|
||||
let r =
|
||||
let objr = Pdf.addobj pdf (Pdf.Dictionary [("/Type", Pdf.Name "/ObjR"); ("/Obj", Pdf.Indirect annot_i)]) in
|
||||
let objr = Pdf.addobj pdf (Pdf.Dictionary [("/Type", Pdf.Name "/OBJR"); ("/Obj", Pdf.Indirect annot_i)]) in
|
||||
Pdf.addobj pdf
|
||||
(Pdf.Dictionary [("/Type", Pdf.Name "/StructElem");
|
||||
("/S", Pdf.Name "/Link");
|
||||
(Pdf.Dictionary [("/S", Pdf.Name "/Link");
|
||||
("/K", Pdf.Array [Pdf.Integer !mcid; Pdf.Indirect objr])])
|
||||
in
|
||||
incr mcid; r)
|
||||
|
@ -645,12 +645,12 @@ let matterhorn_19_003 st st2 pdf =
|
||||
|
||||
(* ID entry of the <Note> tag is non-unique. *)
|
||||
let matterhorn_19_004 _ _ pdf =
|
||||
(* Looking for /Type /StructElem /N /Note /ID to exist. *)
|
||||
(* Looking for /S /Note /ID to exist. *)
|
||||
let ids = ref [] in
|
||||
Pdf.objiter
|
||||
(fun _ x ->
|
||||
match Pdf.lookup_direct pdf "/Type" x, Pdf.lookup_direct pdf "/S" x, Pdf.lookup_direct pdf "/ID" x with
|
||||
| Some (Pdf.Name "/StructElem"), Some (Pdf.Name "/Note"), Some (Pdf.String s) -> ids := s::!ids
|
||||
match Pdf.lookup_direct pdf "/S" x, Pdf.lookup_direct pdf "/ID" x with
|
||||
| Some (Pdf.Name "/Note"), Some (Pdf.String s) -> ids := s::!ids
|
||||
| _ -> ())
|
||||
pdf;
|
||||
if length (setify_large !ids) < length !ids then merror ()
|
||||
|
Reference in New Issue
Block a user