mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
Clean up docs for -obj
This commit is contained in:
@@ -3641,10 +3641,11 @@ let build_enc () =
|
||||
|
||||
let print_obj json pdf objspec =
|
||||
let obj = Cpdftweak.find_obj pdf objspec in
|
||||
let trim s = implode (rev (tl (rev (tl (explode s))))) in
|
||||
if json then
|
||||
print_string (Cpdfyojson.Safe.pretty_to_string (Cpdfjson.json_of_object ~utf8:true pdf (fun _ -> ()) ~no_stream_data:false ~parse_content:false obj))
|
||||
else
|
||||
Printf.printf "%S\n" (Pdfwrite.string_of_pdf obj)
|
||||
print_endline (trim (Printf.sprintf "%S" (Pdfwrite.string_of_pdf obj)))
|
||||
|
||||
let extract_stream_find_obj pdf objspec =
|
||||
int_of_string objspec
|
||||
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
@@ -6559,50 +6559,69 @@ The \texttt{-remove-clipping} operation removes any clipping paths on given page
|
||||
|
||||
{\small\begin{verbatim}
|
||||
$ cpdf -obj 0 in.pdf
|
||||
"<</Root 1256 0 R/Length 588/ID[('\029\\t>\249\157\182F_\153V\175z[\234\196)
|
||||
('\029\\t>\249\157\182F_\153V\175z[\234\196)]/Info 1351 0 R/Size 1406>>"
|
||||
<</Root 1256 0 R/Length 588/ID[('\029\\t>\249\157\182F_\153V\175z[\234\196)
|
||||
('\029\\t>\249\157\182F_\153V\175z[\234\196)]/Info 1351 0 R/Size 1406>>
|
||||
|
||||
$ cpdf -obj 1256 in.pdf
|
||||
"<</OpenAction 1238 0 R/PageLabels<</Nums[0<</S/r>>16<</S/D>>]>>/PageMode
|
||||
/UseOutlines/Names 924 0 R/Outlines 838 0 R/Pages 851 0 R/Type/Catalog>>"
|
||||
<</OpenAction 1238 0 R/PageLabels<</Nums[0<</S/r>>16<</S/D>>]>>/PageMode
|
||||
/UseOutlines/Names 924 0 R/Outlines 838 0 R/Pages 851 0 R/Type/Catalog>>
|
||||
|
||||
$ cpdf -obj 1238 out.pdf
|
||||
"<</D[1225 0 R/Fit]/S/GoTo>>"
|
||||
<</D[1225 0 R/Fit]/S/GoTo>>
|
||||
\end{verbatim}}
|
||||
|
||||
\noindent Alternatively, we may follow a chain of dictionary entries from the trailer dictionary:
|
||||
|
||||
{\small\begin{verbatim}
|
||||
$ ./cpdf -obj /Root/Pages/Count cpdfmanual.pdf
|
||||
"133"
|
||||
133
|
||||
\end{verbatim}}
|
||||
|
||||
\noindent Or, from a given object number:
|
||||
|
||||
{\small\begin{verbatim}
|
||||
$ ./cpdf -obj 1256/PageLabels/Nums cpdfmanual.pdf
|
||||
[0<</S/r>>16<</S/D>>]
|
||||
\end{verbatim}}
|
||||
|
||||
\noindent We may also begin at a numbered page instead of at the trailer dictionary:
|
||||
|
||||
{\small\begin{verbatim}
|
||||
./cpdf -obj P20/Resources/Font/F58/BaseFont cpdfmanual.pdf
|
||||
"/MCBERL+URWPalladioL-Roma"
|
||||
/MCBERL+URWPalladioL-Roma
|
||||
\end{verbatim}}
|
||||
|
||||
\noindent If the object does not exist, Cpdf will exit with code 2. To output data in JSON format instead of PDF format, use \texttt{-obj-json} in place of \texttt{-obj}.
|
||||
\noindent To output data in JSON format instead of PDF format, add \texttt{-json}:
|
||||
|
||||
A stream may be extracted with \texttt{-extract-stream} or \texttt{-extract-stream-decompress}, which decompresses it first where possible:
|
||||
{\small\begin{verbatim}
|
||||
./cpdf -obj-json 140/Prev/Prev/Prev cpdfmanual.pdf
|
||||
{ "/Title": 129, "/A": 126, "/Parent": 112, "/Prev": 124, "/Next": 132 }
|
||||
\end{verbatim}}
|
||||
|
||||
\noindent We can follow array entries as well as dictionary entries by giving the index number into the array - here object 0 (the trailer dictionary), dictionary entry \texttt{/ID}, index number 0:
|
||||
|
||||
{\small\begin{verbatim}
|
||||
./cpdf -obj 0/ID/[0] hello.pdf
|
||||
(\232\20625\030\179/\176q:O\202\135\176u\137)
|
||||
\end{verbatim}}
|
||||
|
||||
\noindent A stream may be extracted with \texttt{-extract-stream} or \texttt{-extract-stream-decompress}, which decompresses it first where possible:
|
||||
|
||||
{\small\begin{verbatim}
|
||||
$ cpdf -obj 0 hello.pdf
|
||||
"<</Size 4/Root 4 0 R/ID[(\232\20625\030\179/\176q:O\202\135\176u\137)
|
||||
(\232\20625\030\179/\176q:O\202\135\176u\137)]>>"
|
||||
<</Size 4/Root 4 0 R/ID[(\232\20625\030\179/\176q:O\202\135\176u\137)
|
||||
(\232\20625\030\179/\176q:O\202\135\176u\137)]>>
|
||||
|
||||
$ cpdf -obj 4 hello.pdf
|
||||
"<</Type/Catalog/Pages 1 0 R>>"
|
||||
<</Type/Catalog/Pages 1 0 R>>
|
||||
|
||||
$ cpdf -obj 1 hello.pdf
|
||||
"<</Type/Pages/Kids[3 0 R]/Count 1>>"
|
||||
<</Type/Pages/Kids[3 0 R]/Count 1>>
|
||||
|
||||
$ cpdf -obj 3 hello.pdf
|
||||
"<</Type/Page/Parent 1 0 R/Resources<</Font<</F0<</Type/Font/Subtype/Type1
|
||||
<</Type/Page/Parent 1 0 R/Resources<</Font<</F0<</Type/Font/Subtype/Type1
|
||||
/BaseFont/Times-Italic>>>>>>/MediaBox[0 0 595.275590551 841.88976378]
|
||||
/Rotate 0/Contents[2 0 R]>>"
|
||||
/Rotate 0/Contents[2 0 R]>>
|
||||
|
||||
$ cpdf -extract-stream-decompress 2 hello.pdf -stdout
|
||||
1 0 0 1 50 770 cm BT/F0 36 Tf(Hello, World!)Tj ET
|
||||
|
Reference in New Issue
Block a user