mutool show

The show command will print the specified objects and streams to stdout. Streams are decoded and non-printable characters are represented with a period by default.

mutool show [options] file.pdf ( xref | outline | grep | <path> ) *

Options:

-p password
Use the specified password if the file is encrypted.
-o file
Write output to file instead of stdout.
-e
Print streams in their original encoded (or compressed) form.
-b
Print streams as binary data, and omit the object.
-g
Print objects in a one-line form suitable for grep, and omit stream data.

Specify what to show by using one of the following keywords, or specify a path to an object:

xref
Print the cross reference table.
outline
Print the outline (table of contents).
pages
List the object numbers for every page.
grep
Print all the objects in the file in a compact one-line format suitable for piping to grep.

A path starts with either an object number, a property in the trailer dictionary, or the keyword "trailer" or "pages". Separate elements with a period '.' or slash '/'. Select a page object by using pages/N where N is the page number. The first page is number 1. You can also use '*' as an element to iterate over all array indices or dictionary properties in an object.

Find the number of pages in a document:
mutool show $FILE trailer/Pages/Count
Print the raw content stream of the first page:
mutool show -b $FILE pages/1/Contents
Show all JPEG compressed stream objects:
mutool show $FILE grep | grep '/Filter/DCTDecode'