Skip to main content

📄 pdforensic: PDF forensics toolkit

PyPI version Python versions CI License: MIT

Find out whether a PDF was edited, see what changed, recover its earlier versions, read all of its metadata and learn how it was made. A command-line tool and Python library for PDF forensic analysis, tamper detection and document verification on Linux, macOS and Windows.

uv tool install pdforensic-authentic-check
pdforensic analyze invoice.pdf

New to this? The user guide walks through installation and every feature in plain language, with no programming needed.

What it tells you about a PDF

Question What pdforensic reports
Was this PDF edited after it was created? Every later save still recorded in the file, and exactly which parts each save added, changed or deleted.
What did it say before? Each earlier version, recovered byte for byte as a PDF you can open.
What metadata does it carry? Title, author, dates, creating software (Info dictionary and XMP), file IDs, MD5/SHA-1/SHA-256 hashes, fonts, images, attachments, JavaScript, forms.
How was it made? Exported from Word or Excel, generated by a library (ReportLab, iText, TCPDF and others), printed from a browser, scanned, OCR'd, or post-processed by a PDF editor.
Is the digital signature still intact? What each signature covers and whether anything was added after signing.
Which standard does it claim? PDF/A, PDF/X, PDF/UA, PDF/E and PDF/VT claims, and print-industry preflight tickets.
Is it encrypted or damaged? Encryption details, structural damage, and files that only pretend to be PDFs.

Every finding comes with its evidence and the clause of the PDF standard (ISO 32000) it rests on.

Example: an invoice whose title was changed

$ pdforensic analyze invoice-edited.pdf

Revisions   2    %%EOF markers 2    objects 7    pages 1

Metadata (Info dictionary)
  Producer      MuPDF incremental save
  Title         Invoice 0042 (amended)

Revisions
  1: bytes 0-1385, xref table, +7 ~0 -0 objects
  2: bytes 1385-1807, xref table, +0 ~1 -0 objects
       modified object 5 (Info)

Tamper indicators: level=medium, modified after creation: yes
  [medium] File was saved incrementally 1 time(s) after it was first written
  [low   ] File identifier shows the file changed after creation
  [medium] Producer changed in revision 2
           Revision 1: "ReportLab PDF Library - (opensource)"; revision 2: "MuPDF incremental save".

(Output shortened.) The original is still inside the file. This writes it out, identical byte for byte to the invoice before the change:

$ pdforensic recover invoice-edited.pdf
revision 1  1385 bytes  sha256 830b0ab2dfa5...  invoice-edited-revisions/invoice-edited-rev1.pdf

Install

Requires Python 3.11 or newer; uv fetches it for you.

uv tool install pdforensic-authentic-check   # the command-line tools
uv add pdforensic-authentic-check            # or as a dependency of your Python project
uvx --from pdforensic-authentic-check pdforensic analyze file.pdf   # or run once without installing

Ready-made packages exist for Linux (x86_64, arm64), macOS (Apple Silicon) and Windows (x86_64). First time using a terminal? See Install it in the user guide.

Commands

pdforensic analyze file.pdf                      # readable report
pdforensic analyze file.pdf --json               # full report as JSON
pdforensic analyze locked.pdf --password secret  # password-protected file
pdforensic recover file.pdf                      # write every earlier version to <name>-revisions/
pdforensic recover file.pdf -o folder --all      # choose the folder; include the current version
pdforensic --version

Files are only read: nothing is modified and nothing leaves your computer.

Python

from pdforensic import analyze, recover_revisions, format_report

report = analyze("invoice.pdf")              # a path or bytes; returns a JSON-serializable dict
print(format_report(report))

report["structure"]["revision_count"]        # 2
report["revisions"][1]["changes"]            # [{"object": 5, "change": "modified", "type": "Info"}]
report["tamper"]["level"]                    # "none" | "info" | "low" | "medium" | "high"
report["tamper"]["indicators"]               # each with id, severity, title, detail, basis
report["provenance"]["generation"]           # e.g. "programmatic", "exported_from_application", "scan"

for item in recover_revisions("invoice.pdf", "earlier-versions"):
    print(item["revision"], item["path"], item["sha256"])

All report sections and all 27 findings are described in the user guide.

Read the result carefully

  • Findings are evidence, not proof. A file with no findings may still have been altered and then fully re-saved ("Save As", "Print to PDF"), which erases its history.
  • Counting %%EOF markers is not enough. Files prepared for fast web viewing and every PDF exported from Microsoft Word, Excel or PowerPoint have two markers and have never been edited. The Revisions count accounts for both.
  • Differing file IDs or dates are common in honest files; weigh them with the rest.
  • Signature cryptography is not verified. The report shows what each signature covers.
  • A claim such as PDF/A-1b is what the file declares, not a validation.

Documentation

Document For
User guide Everyone: installation, each command, how to read every result, troubleshooting, glossary.
PDF forensics notes The rules behind each finding, the standards and sources they rest on, speed, and what was verified.
Changelog What changed in each version.
llms.txt A compact description for AI assistants and agents.

How it works

pdforensic is built on qpdf (through pikepdf) for fast, robust parsing, decoding and decryption, plus its own byte-level layer for the history that PDF libraries hide: revision boundaries, superseded objects and raw trailers. A typical document is analyzed in a few milliseconds; a 22 MB file with 127,000 objects in about half a second.

The original pdfresurrect C tool is bundled and built from source (src/pdfresurrect). The four original commands and functions still work:

Command Python What it does
pdf-versions check_no_of_versions(path) number of versions via pdfresurrect -q
pdf-meta extract_pdf_metadata(path) creator information via pdfresurrect -i
pdf-recover recover_pdf_versions(path) writes versions via pdfresurrect -w into <name>-versions/
pdf-eof count_pdf_eof_markers(path) number of %%EOF markers

pdfresurrect does not decode cross-reference streams or XMP and stops on some linearized files; pdforensic analyze covers those cases. See UPSTREAM.md for the vendored version and its patches.

Development

git clone https://github.com/genie360s/pdforensic.git
cd pdforensic
uv sync                 # creates .venv, installs everything, builds pdfresurrect (needs a C compiler)
uv run pytest           # unit, integration, regression and fuzz tests
uv run ruff check .
  • pdforensic/forensics.py builds the report; pdforensic/_pdf.py is the raw byte layer; pdforensic/cli.py is the command.
  • tests/fixtures holds PDFs from real producers; tests/golden holds the stored reports the regression tests compare against (regenerate with PDFORENSIC_UPDATE_GOLDEN=1 uv run pytest tests/test_regression.py).
  • PDFORENSIC_CORPUS=/path/to/pdfs uv run pytest tests/test_corpus.py runs the analyzer over any folder of PDFs.
  • To build pdfresurrect on its own: cmake -B build && cmake --build build --config Release.

Releasing

The version number lives in one place, the VERSION file. The package metadata, pdforensic.__version__, pdforensic --version and the report all read it.

# 1. edit VERSION and CHANGELOG.md, commit, merge to main
git tag "v$(cat VERSION)" && git push origin "v$(cat VERSION)"
# 2. the release workflow checks the tag against VERSION, builds the binaries,
#    wheels and sdist on every platform, and creates the GitHub release
gh release download "v$(cat VERSION)" --pattern "*.whl" --pattern "*.tar.gz" --dir dist
UV_PUBLISH_TOKEN=... uv publish dist/*

To publish from the workflow instead, set the repository variable PUBLISH_TO_PYPI to true and configure PyPI trusted publishing for the pypi environment.

License

MIT License © 2025 Alex Mkwizu. The bundled pdfresurrect source in src/pdfresurrect is BSD-3-Clause, © pdfresurrect authors.

Metadata

Release files for pdforensic-authentic-check 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdforensic-authentic-check 0.2.0
File Size Uploaded Provenance Actions
pdforensic_authentic_check-0.2.0.tar.gz 188.4 kB Without provenance Details for pdforensic_authentic_check-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pdforensic-authentic-check 0.2.0
File Actions
pdforensic_authentic_check-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for pdforensic_authentic_check-0.2.0-py3-none-win_amd64.whl
pdforensic_authentic_check-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for pdforensic_authentic_check-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
pdforensic_authentic_check-0.2.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for pdforensic_authentic_check-0.2.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
pdforensic_authentic_check-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for pdforensic_authentic_check-0.2.0-py3-none-macosx_11_0_arm64.whl

Total release size: 469.0 kB

Release files / pdforensic_authentic_check-0.2.0.tar.gz

Download URL pdforensic_authentic_check-0.2.0.tar.gz
Size 188.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fc80e503aa369e83a0ba8f815f47dfbb0e6470f7ad38cfda16a1bfe08b396f9c
BLAKE2b-256 checksum
How to use checksums
83d2e68bede90397a987596b6e4257d2b849cdab752abc71db7441a3575ce08f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pdforensic_authentic_check-0.2.0-py3-none-win_amd64.whl

Download URL pdforensic_authentic_check-0.2.0-py3-none-win_amd64.whl
Size 58.4 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
76c39d44178f4bed9a097e49d6265abf94c96390ba2e051b013808145cb78dc5
BLAKE2b-256 checksum
How to use checksums
3fd36bc250f6c84d19ff6c06de7a751df4327a27afd629059c388d764a7f9d0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pdforensic_authentic_check-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL pdforensic_authentic_check-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 82.1 kB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
609b956476ae70e37063ebaf56a024bc5c42a83c004e267d66995a739d04ddf0
BLAKE2b-256 checksum
How to use checksums
4f8863c38315fe8d8fe712bb033a3783f64cb182bf34a35886bf0914f4d877ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pdforensic_authentic_check-0.2.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL pdforensic_authentic_check-0.2.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 81.8 kB
Tags Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
26d4c262040c3c21585d7dcc37eddaf56c350a7a5bc9ac5a30c4d35e5598b7a4
BLAKE2b-256 checksum
How to use checksums
49f3260ee5012fd1fc1b89707a394998fa7c664409befde19d8b6c8c984c6fdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pdforensic_authentic_check-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL pdforensic_authentic_check-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 58.3 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
43f7adc6032b2e124c193784eca288783af11edb64b6f17da65738b234b68065
BLAKE2b-256 checksum
How to use checksums
66a24786d663551a13246370815d2d9e49ad1d62cf3a0044b72cb468abbf14b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pdforensic-authentic-check 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page