Skip to content
Lamina PDF
0.9.0
GitHub
Open the web app

Inspect and check PDFs

This page answers three questions about a PDF before you trust it or send it: what it is, whether it’s damaged, and what it holds that its pages don’t show. Run these three commands on files people upload to you, and on files you’re about to publish.

info prints the PDF version, the page count and size, whether the file is encrypted or tagged for screen readers, and its title and author:

Terminal window
$ laminapdf info invoice.pdf
invoice.pdf PDF 1.7 · 1 page · 12 KB · not encrypted · tagged
Title: Invoice 42
Author: Acme Widgets Ltd
Producer: lamina examples
Pages: 595.28 × 841.89 pt

With --json, it prints the same facts as JSON, and --fields keeps only the keys you name. A file that needed repair lists its warnings there too:

Terminal window
$ laminapdf info scan.pdf --json --fields pages,encrypted,warnings
{"encrypted":false,"input":"scan.pdf","pages":1,"schema":"laminapdf.info/1","warnings":[{"code":"xref-repaired","docsUrl":"https://docs.laminapdf.com/reference/codes/xref-repaired/","hint":"check the result; save with a full rewrite, since an incremental update refuses a repaired base","kind":"input","message":"the stored cross-reference data was unusable and was rebuilt by scanning"}]}

Lamina PDF reads damaged files where it can, repairing what it must and warning about each repair. check reads the whole file, every page and every drawing instruction, and reports those warnings. It exits 3 when there were any, so a script can tell a clean file from a repaired one:

Terminal window
$ laminapdf check scan.pdf
warning[xref-repaired]: the stored cross-reference data was unusable and was rebuilt by scanning
scan.pdf: 1 warning · 1 page · 5 objects
$ echo $?
3

--strict makes the first repair an error instead (exit 1). --warnings-ok turns exit 3 into 0, for a job that only fails on files it can’t read.

check also finds redactions that hide text without removing it, so the text can still be copied out of the file. It warns about three kinds:

  • covered-text: text under a black box or an image, still in the file and still extractable.
  • redaction-not-applied: redaction marks that someone drew but never applied.
  • text-in-earlier-revision: words an earlier version of the file holds and the latest doesn’t. An edited PDF keeps each earlier version inside it.

These stay warnings under --strict, because they aren’t damage. --warnings-ok hides them along with the repairs, so a job that must stop leaked redactions should read the warning codes from --json, not the exit code. To run the same checks from Rust, see Check what a file hides.

A PDF can carry far more than its pages show: earlier versions of itself, metadata, attachments, scripts, comments, form values and text no one can see. reveal lists what a file holds in each of those categories, one line per category it found, and given several files it ends with a count of them:

Terminal window
$ laminapdf reveal letter.pdf brochure.pdf
==> letter.pdf <==
letter.pdf: history
history 2 revisions; revision 0 holds 1 word the latest doesn't
==> brochure.pdf <==
brochure.pdf: metadata, hidden-content
metadata Info: Title; XMP (389 B, 3 namespaces)
hidden-content 24 invisible characters on page 1
2 ok, 0 with warnings, 0 failed, 0 skipped

The letter was edited, and its first version still holds a word the final one removed. The brochure carries 24 characters of invisible text. The categories are:

Category What it lists
history Earlier revisions, what each added, changed and freed, the words they hold that the latest doesn’t, and objects nothing uses
metadata The document information entries, the XMP metadata (a block of extra metadata in XML) with its size and namespaces, and thumbnails
attachments Embedded files, with their names, sizes and types
active-content Scripts and actions, what runs them, and XFA forms (forms described in XML)
annotations Annotations by type, with each comment’s author and text
forms Form fields and their values
hidden-content Hidden text by reason (covered, invisible, off the page, tiny, clipped or too faint to read), layers that are off, unapplied redaction marks, and annotations that lie wholly off their page

In the JSON, activeContent.holders lists the numbers of the objects that hold active content outside any action, such as rich media or a reference to another file.

reveal counts hidden text without printing it. With --json and --include-hidden-text, its report lists each hidden run with its page, its box and its text.

--fail-on names the categories a file must not hold. reveal exits 6 when a file holds any of them, so a release job can stop it:

Terminal window
laminapdf reveal dist/*.pdf --fail-on history,hidden-content,active-content,attachments

--fail-on all names every category. Most files carry some metadata, such as a title, so --fail-on metadata stops most files; leave it out unless you strip metadata before release.

A Rust program gets the same report from Document::reveal: Check what a file hides shows how.

Every warning and error has a code, such as xref-repaired. explain prints that code’s page: what happened, why, and how to fix it. Here is the start of one:

Terminal window
$ laminapdf explain xref-repaired | head -n 8
# `xref-repaired`
- Type: warning
- Kind: `input` (the input is malformed beyond what tolerance repairs)
## What happened
The stored cross-reference data was unusable and was rebuilt by scanning the file.

The same pages are on this site under error and warning codes.

Next: extract text and render pages.