From a147fb6f6275ece69c31f517929a31185db0b0e7 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Mon, 2 Sep 2024 17:46:48 +0100 Subject: [PATCH] beginnings of replace_obj --- cpdfcommand.ml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index ed493c7..3504643 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -3474,8 +3474,27 @@ let print_obj pdf objspec = | [] -> simple_obj 0 | _ -> simple_obj (int_of_string objspec) +(* Empty string is trailerdict. Begins with / and it's a chain separated by + commas. Begins with P and it's a page number then a (possibly empty) chain. + Otherwise it's an object number (0 = trailerdict). *) let replace_obj pdf objspec obj = - () + let key, rest = + let r, rest = cleavewhile (neq '/') (rev (explode objspec)) in + (implode ('/'::rev r), implode (rev (tl rest))) + in + () + (*match .... rest .... with + | ...not objnum... -> + (* 1. It's not an object number *) + let chain = + (* 1. Chain with /s *) + (* 2. P plus possibly empty chain *) + [] + in + Pdf.replace_chain pdf chain (k, obj) + (* 2. It is an object number *) + | _ -> + (* Replace chain within object. How? *)*) (* Main function *) let go () =