diff --git a/cpdfcommand.ml b/cpdfcommand.ml index d5e88ce..32aa009 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1737,16 +1737,21 @@ let setreplacedictentry s = let setprintdictentry s = setop (PrintDictEntry s) () +let pdf_or_json s = + match explode s with + | 'P'::'D'::'F'::r -> Pdfread.parse_single_object (implode r) + | _ -> Cpdfjson.object_of_json (Cpdfyojson.Safe.from_string s) + let setreplacedictentryvalue s = try - let pdfobj = Cpdfjson.object_of_json (Cpdfyojson.Safe.from_string s) in + let pdfobj = pdf_or_json s in args.replace_dict_entry_value <- pdfobj with e -> error (Printf.sprintf "Failed to parse replacement value: %s\n" (Printexc.to_string e)) let setdictentrysearch s = try - let pdfobj = Cpdfjson.object_of_json (Cpdfyojson.Safe.from_string s) in + let pdfobj = pdf_or_json s in args.dict_entry_search <- Some pdfobj with e -> error (Printf.sprintf "Failed to parse search term: %s\n" (Printexc.to_string e)) @@ -1966,7 +1971,7 @@ let setreadableops () = let addeltinfo s = match String.split_on_char '=' s with | h::t -> - let pdfobj = Pdfread.parse_single_object (String.concat "" t) in + let pdfobj = pdf_or_json (String.concat "" t) in Cpdfdrawcontrol.eltinfo h pdfobj | [] -> error "addeltinfo: bad format" @@ -4684,7 +4689,7 @@ let go () = print_obj args.format_json pdf s | Some (ReplaceObj (a, b)) -> let pdf = get_single_pdf args.op false in - let pdfobj = Cpdfjson.object_of_json (Cpdfyojson.Safe.from_string b) in + let pdfobj = pdf_or_json b in replace_obj pdf a pdfobj; write_pdf false pdf | Some (Verify standard) -> diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index 314eb5d..edd35f9 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 90b7da5..0e7cce7 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -5373,7 +5373,7 @@ By default, Cpdf with \texttt{-draw-struct-tree} will mark anything not automati Some tags require a namespace other than the default. You can set the namespace with \texttt{-namespace}, which affects all future tags until reset. Two namespace abbreviations are available: \texttt{PDF} for the default \texttt{http://iso.org/pdf/ssn} namespace and \texttt{PDF2} for the PDF 2.0 namespace \texttt{http://iso.org/pdf2/ssn}. -Extra information may be added to structure tree nodes with \texttt{-eltinfo} / \texttt{-end-eltinfo}. For example, to set the alternative description for an image, we might write \texttt{-eltinfo "Alt=A large horse" -image A -end-eltinfo}. Multiple items may be set at once, for example Alt, ActualText, Lang etc. +Extra information may be added to structure tree nodes with \texttt{-eltinfo} / \texttt{-end-eltinfo}. For example, to set the alternative description for an image, we might write (in JSON format, or prefixing with \texttt{PDF} in PDF format) \texttt{-eltinfo "Alt=PDF(A large horse)" -image A -end-eltinfo}. Multiple items may be set at once, for example Alt, ActualText, Lang etc. A role map, which maps non-standard structure types to standard ones, may be set with \texttt{-rolemap}. For example \texttt{-rolemap "/S1/H1/S2/H2"} would map the S1 structure type to the standard type H1 and so on.