clean up after testing

This commit is contained in:
John Whitington 2024-09-04 15:30:43 +01:00
parent b03cce5ea1
commit 72e10b19cf
1 changed files with 6 additions and 19 deletions

View File

@ -3477,9 +3477,7 @@ let print_obj pdf objspec =
(* Empty string is trailerdict. Begins with / and it's a chain separated by commas. *) (* Empty string is trailerdict. Begins with / and it's a chain separated by commas. *)
let replace_obj pdf objspec obj = let replace_obj pdf objspec obj =
(*Printf.printf "objspec = %s\n" objspec;*)
let rec find_max_existing to_fake chain = let rec find_max_existing to_fake chain =
(*Printf.printf "find_max_existing: %s\n" (String.concat "" chain);*)
if chain = [] then (chain, to_fake) else if chain = [] then (chain, to_fake) else
match Pdf.lookup_chain pdf pdf.Pdf.trailerdict chain with match Pdf.lookup_chain pdf pdf.Pdf.trailerdict chain with
| None -> find_max_existing (hd (rev chain)::to_fake) (rev (tl (rev chain))) | None -> find_max_existing (hd (rev chain)::to_fake) (rev (tl (rev chain)))
@ -3490,25 +3488,14 @@ let replace_obj pdf objspec obj =
| h::t -> Pdf.Dictionary [(h, wrap_obj obj t)] | h::t -> Pdf.Dictionary [(h, wrap_obj obj t)]
in in
let chain, to_fake = find_max_existing [] (split_chain objspec) in let chain, to_fake = find_max_existing [] (split_chain objspec) in
(*Printf.printf "chain:\n";
iter (Printf.printf "%s ") chain;
Printf.printf "\n";
Printf.printf "to_fake is:\n";
iter (Printf.printf "%s ") to_fake;
Printf.printf "\n";*)
let chain, key, obj = let chain, key, obj =
match to_fake with match to_fake with
| [] -> | [] -> (rev (tl (rev chain)), hd (rev chain), obj)
(* If chain is complete (i.e to_fake empty), split the key off, and the obj is unaltered *) | h::t -> (chain, h, wrap_obj obj t)
(rev (tl (rev chain)), hd (rev chain), obj)
| h::t ->
(* Otherwise to_fake has head. That's the key, and the object is the rest wrapped. *)
(chain, h, wrap_obj obj t)
in in
(*Printf.printf "final chain:\n"; if chain = [] then
iter (Printf.printf "%s ") chain; pdf.Pdf.trailerdict <- Pdf.add_dict_entry pdf.Pdf.trailerdict key obj
Printf.printf "key is %s\n" key; else
Printf.printf "obj is %s\n" (Pdfwrite.string_of_pdf obj);*)
Pdf.replace_chain pdf chain (key, obj) Pdf.replace_chain pdf chain (key, obj)
(* Main function *) (* Main function *)