Document JSON/PDF versions of -obj -replace-obj

This commit is contained in:
John Whitington 2024-11-08 15:17:15 +00:00
parent a09db99106
commit 73cc320ecc
3 changed files with 14 additions and 4 deletions

View File

@ -2974,7 +2974,7 @@ let specs =
("-extract-stream", Arg.String setextractstream, " Extract a stream"); ("-extract-stream", Arg.String setextractstream, " Extract a stream");
("-extract-stream-decompress", Arg.String setextractstreamdecomp, " Extract a stream, decompressing"); ("-extract-stream-decompress", Arg.String setextractstreamdecomp, " Extract a stream, decompressing");
("-obj", Arg.String setprintobj, " Print object"); ("-obj", Arg.String setprintobj, " Print object");
("-obj-json", Arg.String setprintobjjson, " Print object"); ("-obj-json", Arg.String setprintobjjson, " Print object in JSON format");
("-replace-obj", Arg.String setreplaceobj, "Replace object"); ("-replace-obj", Arg.String setreplaceobj, "Replace object");
("-json", Arg.Unit (fun () -> args.format_json <- true), " Format output as JSON"); ("-json", Arg.Unit (fun () -> args.format_json <- true), " Format output as JSON");
("-verify", Arg.String (fun s -> setop (Verify s) ()), " Verify conformance to a standard"); ("-verify", Arg.String (fun s -> setop (Verify s) ()), " Verify conformance to a standard");

Binary file not shown.

View File

@ -5744,7 +5744,7 @@ Cpdf can add PDF/UA structure data when drawing on new PDF/UA files. For example
\noindent\verb!cpdf -remove-clipping [<range>] in.pdf -o out.pdf! \noindent\verb!cpdf -remove-clipping [<range>] in.pdf -o out.pdf!
\vspace{1.5mm} \vspace{1.5mm}
\noindent\verb!cpdf -obj <object specification> in.pdf! \noindent\verb!cpdf -obj[-json] <object specification> in.pdf!
\vspace{1.5mm} \vspace{1.5mm}
\noindent\verb!cpdf -replace-obj <object specification>=<object> in.pdf! \noindent\verb!cpdf -replace-obj <object specification>=<object> in.pdf!
@ -5976,7 +5976,9 @@ $ ./cpdf -obj /Root/Pages/Count cpdfmanual.pdf
"/MCBERL+URWPalladioL-Roma" "/MCBERL+URWPalladioL-Roma"
\end{verbatim}} \end{verbatim}}
\noindent A stream may be extracted with \texttt{-extract-stream} or \texttt{-extract-stream-decompress}, which decompresses it first where possible: \noindent To output data in JSON format instead of PDF format, use \texttt{-obj-json} in place of \texttt{-obj}.
A stream may be extracted with \texttt{-extract-stream} or \texttt{-extract-stream-decompress}, which decompresses it first where possible:
{\small\begin{verbatim} {\small\begin{verbatim}
$ cpdf -obj 0 hello.pdf $ cpdf -obj 0 hello.pdf
@ -6000,13 +6002,21 @@ $ cpdf -extract-stream-decompress 2 hello.pdf -stdout
\noindent By these mechanisms, ad-hoc exploration of PDF files is possible. \noindent By these mechanisms, ad-hoc exploration of PDF files is possible.
We may also edit dictionary entries with \texttt{-replace-obj} by giving an object specification, and the new value in JSON format: We may also edit dictionary entries with \texttt{-replace-obj} by giving an object specification, and the new value in JSON or PDF format (prefix with "PDF" to denote PDF format):
\begin{framed} \begin{framed}
\small\noindent\verb!cpdf -replace-obj /Root/MarkInfo/Marked=true in.pdf -o out.pdf! \small\noindent\verb!cpdf -replace-obj /Root/MarkInfo/Marked=true in.pdf -o out.pdf!
\vspace{2.5mm} \vspace{2.5mm}
\noindent Replace or add dictionary entry in \texttt{in.pdf}, writing to \texttt{out.pdf}. \noindent Replace or add dictionary entry in \texttt{in.pdf}, writing to \texttt{out.pdf}.
\vspace{2.5mm}
\small\noindent\verb!cpdf -replace-obj '/Root/Info/Title=PDF(New title)' in.pdf -o out.pdf!
\vspace{2.5mm}
\noindent Replace or add dictionary entry in \texttt{in.pdf}, writing to \texttt{out.pdf}.
\end{framed} \end{framed}
\noindent Any part of the object specification not already present will be fabricated using direct nested dictionaries. For example, if \texttt{/MarkInfo} does not exist in the root dictionary, this command adds \texttt{/MarkInfo <</Marked true>>} to the root dictionary. \noindent Any part of the object specification not already present will be fabricated using direct nested dictionaries. For example, if \texttt{/MarkInfo} does not exist in the root dictionary, this command adds \texttt{/MarkInfo <</Marked true>>} to the root dictionary.