mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-02-12 01:40:38 +01:00
Rearranged -print-dict-entry and added JSON format
This commit is contained in:
parent
8c22c19415
commit
7a91de2939
@ -4731,7 +4731,10 @@ let go () =
|
||||
write_pdf false pdf
|
||||
| Some (PrintDictEntry key) ->
|
||||
let pdf = get_single_pdf args.op true in
|
||||
Cpdftweak.print_dict_entry ~utf8:(args.encoding = Cpdfmetadata.UTF8) pdf key
|
||||
if args.format_json then
|
||||
print_string (Pdfio.string_of_bytes (Cpdftweak.get_dict_entries ~utf8:(args.encoding = Cpdfmetadata.UTF8) pdf key))
|
||||
else
|
||||
Cpdftweak.print_dict_entry ~utf8:(args.encoding = Cpdfmetadata.UTF8) pdf key
|
||||
| Some ListSpotColours ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
Cpdfspot.list_spot_colours pdf
|
||||
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
@ -6326,7 +6326,7 @@ Cpdf can add PDF/UA structure data when drawing on new PDF/UA files. For example
|
||||
\noindent\verb!cpdf -list-spot-colors in.pdf!
|
||||
|
||||
\vspace{1.5mm}
|
||||
\noindent\verb!cpdf -print-dict-entry <key> in.pdf!
|
||||
\noindent\verb!cpdf -print-dict-entry[-json] <key> in.pdf!
|
||||
|
||||
\vspace{1.5mm}
|
||||
\noindent\verb!cpdf -remove-dict-entry <key> [-dict-entry-search <term>]!\\
|
||||
@ -6346,10 +6346,12 @@ Cpdf can add PDF/UA structure data when drawing on new PDF/UA files. For example
|
||||
\noindent\verb!cpdf -replace-obj <object specification>=<object> in.pdf!
|
||||
|
||||
\vspace{1.5mm}
|
||||
\noindent\verb!cpdf -extract-stream[-decompress] <obj num> in.pdf [-o out.dat | -stdout]!
|
||||
\noindent\verb!cpdf -extract-stream[-decompress] <object specification>!\\
|
||||
\noindent\verb! in.pdf [-o out.dat | -stdout]!
|
||||
|
||||
\vspace{1.5mm}
|
||||
\noindent\verb!cpdf -replace-stream <obj num> -replace-stream-with <filename>!\\
|
||||
\noindent\verb!cpdf -replace-stream <object specification>!\\
|
||||
\noindent\verb! -replace-stream-with <filename>!\\
|
||||
\noindent\verb! in.pdf -o out.pdf!\end{framed}}
|
||||
\section{Draft Documents}
|
||||
\index{draft}
|
||||
@ -6501,10 +6503,10 @@ This is for editing data within the PDF's internal representation. Use with caut
|
||||
\small\noindent\verb!cpdf -print-dict-entry /URI in.pdf!
|
||||
|
||||
\vspace{2.5mm}
|
||||
\noindent Print all URLs in annotation hyperlinks in \texttt{in.pdf}.
|
||||
\noindent Print all URLs in annotation hyperlinks in \texttt{in.pdf}, one per line.
|
||||
\end{framed}
|
||||
|
||||
\noindent To remove a dictionary entry:
|
||||
\noindent To report data in JSON format, add \texttt{-json}. To remove a dictionary entry:
|
||||
|
||||
\begin{framed}
|
||||
\small\noindent\verb!cpdf -remove-dict-entry /One in.pdf -o out.pdf!
|
||||
|
@ -266,16 +266,12 @@ let replace_dict_entry pdf key value search =
|
||||
let print_dict_entry ~utf8 pdf key =
|
||||
let f d =
|
||||
match Pdf.lookup_direct pdf key d with
|
||||
| Some v ->
|
||||
(* We use a double newline as a separator. *)
|
||||
Printf.printf "%s\n\n" (Cpdfyojson.Safe.to_string (Cpdfjson.json_of_object ~utf8 ~clean_strings:true pdf (fun _ -> ()) ~no_stream_data:false ~parse_content:false v));
|
||||
d
|
||||
| Some v -> Printf.printf "%s\n" (Pdfwrite.string_of_pdf v); d
|
||||
| None -> d
|
||||
in
|
||||
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
||||
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict
|
||||
|
||||
(* For cpdflib. *)
|
||||
let get_dict_entries ~utf8 pdf key =
|
||||
let es = ref [] in
|
||||
let f d =
|
||||
|
Loading…
x
Reference in New Issue
Block a user