next up previous contents index
Next: Joining several commmands with Up: Basic Usage Previous: Decryption   Contents   Index


Standard Input and Standard Output

Thus far, we have assumed that the input PDF will be read from a file on disk, and the output written similarly. Often it's useful to be able to read input from stdin (Standard Input) or write output to stdout (Standard Output) instead. The typical use is to join several programs together into a pipe, passing data from one to the next without the use of intermediate files. Use -stdin to read from standard input, and -stdout to write to standard input, either to pipe data between multiple programs, or multiple invocations of the same program.

For example, this sequence of commands (all typed on one line)


\begin{framed}
\small\begin{verbatim}
cpdf in.pdf reverse -stdout \vert
cpdf ...
...in 1-5 -stdout \vert
cpdf -stdin reverse -o out.pdf\end{verbatim}
\end{framed}

extracts the last five pages of in.pdf in the correct order, writing them to out.pdf. It does this by reversing the input, taking the first five pages and then reversing the result.

Using -stdout on the final command in the pipeline to output the PDF to screen is not recommended, since PDF files often contain compressed sections which are not screen-readable.

Several cpdf operations write to standard output by default (for example, listing fonts). A useful feature of the command line (not specific to cpdf) is the ability to redirect this output to a file. This is achieved with the > operator:


\begin{framed}
\small\verb!cpdf -info in.pdf > file.txt!
\par
\vspace{2.5mm}
\...
...ion (See \Sref{info}), redirecting the
output to \texttt{file.txt}.
\end{framed}


next up previous contents index
Next: Joining several commmands with Up: Basic Usage Previous: Decryption   Contents   Index
root 2008-12-01