Inspect PDF Metadata and Page Geometry with pdfinfo
You will use pdfinfo to inspect a PDF without changing it, read its document metadata, check its page count and dimensions, and diagnose a missing input file. The examples use Poppler 24.02.0 from Ubuntu package poppler-utils 24.02.0-1ubuntu9.9.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a shell, a readable PDF and the poppler-utils package. These commands are read-only. They do not edit the PDF, but some options can expose sensitive metadata, URLs or embedded JavaScript in 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 does not need 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 are only relevant when the input directory itself is not readable.
2. Print the ordinary document summary
Pass one PDF path as the final argument. This example uses an installed specification PDF; replace it with 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 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 check the useful fields for your task: Pages, Encrypted, Page size, File size and PDF version. The command has not written a replacement file.
3. Inspect a page range and its boxes
Use -f for the first page, -l for the last page 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
Use a bounded range when you are checking a particular page or when a large document would make a full report 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 the context of the PDF layout you are troubleshooting.
4. Choose a date and metadata format
For machine-readable dates, add -isodates. 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 when you need the undecoded strings stored in the PDF itself. These two switches describe dates; they do not rewrite them. The ordinary output may display a local time zone, so do not compare it as plain text with an ISO timestamp.
For the document-level XML Metadata stream, use -meta. For standard and custom metadata together, use -custom. These are alternative report modes: each requested-information option prints only that requested information instead of the normal summary.
5. Treat extracted content as untrusted
Several report modes reveal data that may be useful for analysis but should not be treated as safe input. -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. -struct-text includes text with that structure and can be slow for a large file. -listenc lists encodings supported by this build, including UTF-8; it does not inspect the PDF:
$ 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. A status of 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 contains 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. This is useful when another 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
For an encrypted PDF, the normal report may require credentials. -upw supplies the user password and -opw supplies 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 those options in shared environments; use a safer credential-handling arrangement if your workflow genuinely requires them.
Done means
pdfinfo -videntified the Poppler version you are using.- The ordinary report confirmed the intended file, page count, size and encryption state.
- You used
-box,-isodatesor a focused report mode only where its output was needed. - You treated URLs, JavaScript, metadata and passwords as potentially sensitive.
- A non-zero exit status was captured and interpreted instead of being ignored.