Home / Alt manpages / pdfinfo(1)

  • pdfinfo(1)
  • User command
  • linux

Inspect PDF Metadata and Page Geometry with pdfinfo

pdfinfo reads a PDF's document metadata, page count and dimensions, without changing a single byte of it. The examples use Poppler 24.02.0 from Ubuntu package poppler-utils 24.02.0-1ubuntu9.9.

Allow about ten minutes. You need a shell, a readable PDF and the poppler-utils package. These commands are read-only, but some options can print sensitive metadata, URLs or embedded JavaScript straight to your terminal, so choose the input and output location deliberately.

1. Check the installed command

Confirm which executable will run and record its version. This is an ordinary command and needs no elevated privileges:

$ command -v pdfinfo
/usr/bin/pdfinfo
$ pdfinfo -v
pdfinfo version 24.02.0
Copyright 2005-2024 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC

Checkpoint

If command -v prints nothing, install or enable the package through your normal system-management process. Do not use sudo merely to inspect a PDF; elevated privileges only matter when the input directory itself is unreadable.

2. Print the ordinary document summary

Pass one PDF path as the final argument. This example uses an installed specification PDF; swap in your own path:

$ pdfinfo /usr/share/doc/shared-mime-info/shared-mime-info-spec.pdf
Title:
Subject:
Keywords:
Author:
Creator:         LaTeX with hyperref
Producer:        pdfTeX-1.40.25
CreationDate:    Mon Apr  1 12:58:12 2024 BST
ModDate:         Mon Apr  1 12:58:12 2024 BST
Custom Metadata: yes
Metadata Stream: no
Tagged:          no
UserProperties:  no
Suspects:        no
Form:            none
JavaScript:      no
Pages:           19
Encrypted:       no
Page size:       609.714 x 789.041 pts
Page rot:        0
File size:       147924 bytes
Optimized:       no
PDF version:     1.5

The standard report combines values from the PDF Info dictionary with structural and file details. Blank fields are not failures: this file simply has no title, subject, keywords or author. Page sizes are points, and the default report describes the document rather than listing every page.

Checkpoint

Confirm the input is the file you intended, then read the fields that matter for your task: Pages, Encrypted, Page size, File size and PDF version. Nothing has been written back.

3. Inspect a page range and its boxes

Use -f for the first page, -l for the last, and -box for page bounding boxes. A range makes the output page-specific:

$ pdfinfo -box -f 1 -l 1 /usr/share/doc/shared-mime-info/shared-mime-info-spec.pdf
Page    1 size:  609.714 x 789.041 pts
Page    1 rot:   0
Page    1 MediaBox:      0.00     0.00   609.71   789.04
Page    1 CropBox:       0.00     0.00   609.71   789.04
Page    1 BleedBox:      0.00     0.00   609.71   789.04
Page    1 TrimBox:       0.00     0.00   609.71   789.04
Page    1 ArtBox:        0.00     0.00   609.71   789.04

Reach for a bounded range when checking one page, or when a full report on a large document would be distracting. The boxes are PDF coordinates, not CSS pixels. A missing optional box can be reported using a value inherited from another box, so interpret the result in context.

4. Choose a date and metadata format

Add -isodates for machine-readable dates: the same report then uses an ISO-8601 timestamp with its time zone:

$ pdfinfo -isodates /usr/share/doc/shared-mime-info/shared-mime-info-spec.pdf | sed -n '1,12p'
Title:
Subject:
Keywords:
Author:
Creator:         LaTeX with hyperref
Producer:        pdfTeX-1.40.25
CreationDate:    2024-04-01T11:58:12Z
ModDate:         2024-04-01T11:58:12Z

Use -rawdates for the undecoded strings stored in the PDF itself. Both switches describe dates; neither rewrites them. Ordinary output may show a local time zone, so do not compare it as plain text against an ISO timestamp.

  • -meta prints the document-level XML Metadata stream.
  • -custom prints standard and custom metadata together.

These are alternative report modes: each requested-information option prints only that information instead of the normal summary.

5. Treat extracted content as untrusted

Several report modes reveal data worth analysing but never worth trusting outright:

  • -url lists supported URL annotations; it does not scan visible text for strings beginning with http://.
  • -js prints PDF JavaScript. Do not pipe either result into a shell, open links automatically, or execute printed JavaScript.
  • -struct prints the logical structure of a Tagged PDF, and -struct-text includes text with that structure, which can be slow on a large file.
  • -listenc lists encodings this build supports, including UTF-8; it does not inspect the PDF at all:
$ pdfinfo -listenc | sed -n '1,5p'
Available encodings are:
ASCII7
Big5
Big5ascii
EUC-CN

Checkpoint

Keep diagnostic output in a file only when its metadata is acceptable for that location. PDF titles, authors, URLs and embedded scripts can contain information you did not intend to disclose.

6. Read failures and use standard input

Exit status 0 means no error. 1 means the PDF could not be opened, 2 means an output file could not be opened, 3 indicates a PDF permission error, and 99 means another error. Capture the status immediately:

$ pdfinfo /does/not/exist.pdf >/tmp/pdfinfo.out 2>&1
$ status=$?
$ printf 'pdfinfo status: %s\n' "$status"
pdfinfo status: 1
$ sed -n '1,2p' /tmp/pdfinfo.out
I/O Error: Couldn't open file '/does/not/exist.pdf': No such file or directory.

The temporary file above holds diagnostic output and can be removed after review. Do not put passwords or confidential PDFs in a shared temporary directory.

A single hyphen makes pdfinfo read the PDF from standard input, useful when a trusted program supplies bytes, but it can hide which file was examined, so log that provenance separately:

$ cat /path/to/document.pdf | pdfinfo -
Title:
Subject:
...
Pages:           19

Security warning

For an encrypted PDF, the normal report may require credentials: -upw supplies the user password and -opw the owner password. Command-line passwords can be visible in process listings and shell history, and an owner password bypasses security restrictions according to the installed manual. Avoid these options in shared environments, and use a safer credential-handling arrangement if your workflow genuinely requires them.

Done means

  • Version identified: pdfinfo -v confirmed the Poppler version in use.
  • Summary confirmed: the ordinary report shows the intended file, page count, size and encryption state.
  • Extra modes used sparingly: -box, -isodates or a focused report mode only where needed.
  • Sensitive output handled carefully: URLs, JavaScript, metadata and passwords treated as potentially sensitive.
  • Non-zero exit status captured: and interpreted instead of ignored.