pdfdebug inspects the internal structure of a PDF from the command line: its
object tree, indirect objects, content streams, fonts, images, cross-reference
table, embedded files, metadata, and digital signatures. It also runs bounded
structural checks and computes a structural diff between two PDFs.
Everything is read-only - pdfdebug never modifies the file you point it at.
This page documents the pdfdebug command-line tool, not the "UniDoc PDF
Debugger" desktop application (the GUI counterpart); for the desktop app and the
project as a whole, see the README.
pdfdebug validate --profile pdfua-1-structural file.pdf
After the profile name and its scope sentence, the output lists the rules it
checked with 0 found or N found beside each, then the problems and a
summary line. The profile checks catalog-level entries only, such as whether
the document is marked as tagged. A file that passes every one of them can
still fail PDF/UA, so a clean run is not a verdict; use veraPDF for that.
pdfdebug --help lists the current rules of each profile.
pdfdebug diff old.pdf new.pdf
Nodes are matched by structural path (/Root/Pages/Kids[0]), not by object
number, so a file that was rewritten with renumbered objects still lines up.
After a summary line, each node is marked + added, - removed or ~
changed; --full also prints the unchanged nodes. The command exits 1 when the
files differ.
pdfdebug dump images file.pdf
pdfdebug dump image --metadata --ref "4 0 R" file.pdf
dump images lists every image XObject referenced from page resources, with
its reference in the REF column. Pass that reference to dump image --metadata
for the image dictionary and how its samples are interpreted (see
dump image). Without --metadata,
dump image --json also carries the image data in its base64 field, so
jq -r .base64 | base64 -d writes the image. For the decoded bytes of a
page's content stream, use pdfdebug dump stream --raw --page 1 file.pdf > page1.txt,
or --ref for any stream object. An attachment comes out with
pdfdebug dump embedded --name NAME file.pdf > out; run
dump embedded file.pdf first to see the names.
pdfdebug validate --json --profile pdfua-1-structural file.pdf > report.json
Branch on the exit code first and read summary from the JSON second, because
pdfua-1-structural findings are warnings and a rule that could not run is
info, and both exit 0. The full script is under
Exit codes.
Each description links to the command's section on its reference page.
Every command also takes --json, and most take --pretty. The flags shared
across commands are defined under Flags.
pdfdebug <command> [subcommand] [flags] <file.pdf>
Most inspection lives under dump. validate and diff are top-level peers.
Flags go before the file, not after it. Argument parsing stops at the first
non-flag argument, so dump tree file.pdf --json would leave --json unparsed;
the command rejects it with the usage line rather than quietly printing plain
text. That covers a required selector too: dump page file.pdf --info 1 is the
same shape error, reported the same way, not a missing --info. A flag value
the command would also reject changes nothing: dump tree --page 0 file.pdf --json draws the usage line, not the out-of-range --page. Every command takes
one file except diff, which takes two.
These recur across commands; each is defined once here, and each command's synopsis on its reference page shows which of them it takes.
--json- emit structured JSON instead of the default plain text.--pretty- indent JSON output (no effect on plain text).--depth N- limit tree traversal to N levels (dump tree).--resolve- follow indirect references inline;--resolve-depth Nbounds how deep.--raw- emit the raw stream/object bytes (a separate machine format).--ops- emit the parsed content-stream operators (dump stream).--page N/--ref "N G R"/--xobject NAME- select what to dump.--refaccepts two forms:"N G R"(e.g."7 0 R") andobj:G:N(e.g.obj:0:7).--metadata- fordump image, report metadata and omit the base64 payload in JSON.--glyphs- fordump font, print the full per-code mapping table.--name NAME- fordump embedded, extract the named file's bytes to stdout.--profile- forvalidate, select the profile.--full- fordiff, include unchanged nodes in the output.--help/-h- show usage. Every command also accepts--help.--version/-v- show version information.
- Structure:
dump tree,dump object,dump objects,dump source,dump reverserefsanddump xref. - Pages and content:
dump pages,dump page,dump streamanddump bytes. - Images and fonts:
dump images,dump imageanddump font. - Document data:
dump embedded,dump metadataanddump signatures. - Validate and diff:
validateanddiff. - Scripting: exit codes, a CI script, what is and is not machine output, and the update notice and how to turn it off.