More PDF/JSON work
This commit is contained in:
parent
73cc320ecc
commit
cec68cbae7
|
@ -1737,16 +1737,21 @@ let setreplacedictentry s =
|
||||||
let setprintdictentry s =
|
let setprintdictentry s =
|
||||||
setop (PrintDictEntry 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 =
|
let setreplacedictentryvalue s =
|
||||||
try
|
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
|
args.replace_dict_entry_value <- pdfobj
|
||||||
with
|
with
|
||||||
e -> error (Printf.sprintf "Failed to parse replacement value: %s\n" (Printexc.to_string e))
|
e -> error (Printf.sprintf "Failed to parse replacement value: %s\n" (Printexc.to_string e))
|
||||||
|
|
||||||
let setdictentrysearch s =
|
let setdictentrysearch s =
|
||||||
try
|
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
|
args.dict_entry_search <- Some pdfobj
|
||||||
with
|
with
|
||||||
e -> error (Printf.sprintf "Failed to parse search term: %s\n" (Printexc.to_string e))
|
e -> error (Printf.sprintf "Failed to parse search term: %s\n" (Printexc.to_string e))
|
||||||
|
@ -1966,7 +1971,7 @@ let setreadableops () =
|
||||||
let addeltinfo s =
|
let addeltinfo s =
|
||||||
match String.split_on_char '=' s with
|
match String.split_on_char '=' s with
|
||||||
| h::t ->
|
| 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
|
Cpdfdrawcontrol.eltinfo h pdfobj
|
||||||
| [] -> error "addeltinfo: bad format"
|
| [] -> error "addeltinfo: bad format"
|
||||||
|
|
||||||
|
@ -4684,7 +4689,7 @@ let go () =
|
||||||
print_obj args.format_json pdf s
|
print_obj args.format_json pdf s
|
||||||
| Some (ReplaceObj (a, b)) ->
|
| Some (ReplaceObj (a, b)) ->
|
||||||
let pdf = get_single_pdf args.op false in
|
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;
|
replace_obj pdf a pdfobj;
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| Some (Verify standard) ->
|
| Some (Verify standard) ->
|
||||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -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}.
|
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.
|
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.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue