mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
Rearranged -print-dict-entry and added JSON format
This commit is contained in:
@ -4731,6 +4731,9 @@ let go () =
|
|||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| Some (PrintDictEntry key) ->
|
| Some (PrintDictEntry key) ->
|
||||||
let pdf = get_single_pdf args.op true in
|
let pdf = get_single_pdf args.op true in
|
||||||
|
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
|
Cpdftweak.print_dict_entry ~utf8:(args.encoding = Cpdfmetadata.UTF8) pdf key
|
||||||
| Some ListSpotColours ->
|
| Some ListSpotColours ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
|
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!
|
\noindent\verb!cpdf -list-spot-colors in.pdf!
|
||||||
|
|
||||||
\vspace{1.5mm}
|
\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}
|
\vspace{1.5mm}
|
||||||
\noindent\verb!cpdf -remove-dict-entry <key> [-dict-entry-search <term>]!\\
|
\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!
|
\noindent\verb!cpdf -replace-obj <object specification>=<object> in.pdf!
|
||||||
|
|
||||||
\vspace{1.5mm}
|
\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}
|
\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}}
|
\noindent\verb! in.pdf -o out.pdf!\end{framed}}
|
||||||
\section{Draft Documents}
|
\section{Draft Documents}
|
||||||
\index{draft}
|
\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!
|
\small\noindent\verb!cpdf -print-dict-entry /URI in.pdf!
|
||||||
|
|
||||||
\vspace{2.5mm}
|
\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}
|
\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}
|
\begin{framed}
|
||||||
\small\noindent\verb!cpdf -remove-dict-entry /One in.pdf -o out.pdf!
|
\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 print_dict_entry ~utf8 pdf key =
|
||||||
let f d =
|
let f d =
|
||||||
match Pdf.lookup_direct pdf key d with
|
match Pdf.lookup_direct pdf key d with
|
||||||
| Some v ->
|
| Some v -> Printf.printf "%s\n" (Pdfwrite.string_of_pdf v); d
|
||||||
(* 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
|
|
||||||
| None -> d
|
| None -> d
|
||||||
in
|
in
|
||||||
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
Pdf.objselfmap (dict_entry_single_object f pdf) pdf;
|
||||||
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict
|
pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict
|
||||||
|
|
||||||
(* For cpdflib. *)
|
|
||||||
let get_dict_entries ~utf8 pdf key =
|
let get_dict_entries ~utf8 pdf key =
|
||||||
let es = ref [] in
|
let es = ref [] in
|
||||||
let f d =
|
let f d =
|
||||||
|
Reference in New Issue
Block a user