Skip to main content

A purpose-built PDF link analysis and reporting tool with GUI and CLI.

Project description

pdflinkcheck

A purpose-built tool for comprehensive analysis of hyperlinks and GoTo links within PDF documents. Users may leverage either the PyMuPDF or the pypdf library. Use the CLI or the GUI.


Screenshot of the pdflinkcheck GUI


📥 Access and Installation

The recommended way to use pdflinkcheck is to either install the CLI with pipx or to download the appropriate latest binary for your system from Releases.

🚀 Release Artifact Files (EXE, PYZ, ELF)

For the most user-typical experience, download the single-file binary matching your OS.

File Type Primary Use Case Recommended Launch Method
Executable (.exe, .elf) GUI Double-click the file.
PYZ (Python Zip App) CLI or GUI Run using your system's python command: python pdflinkcheck-VERSION.pyz --help

Installation via pipx

For an isolated environment where you can access pdflinkcheck from any terminal:

# Ensure you have pipx installed first (if not, run: pip install pipx)
pipx install pdflinkcheck[full]

# On Termux
pipx install pdflinkcheck

💻 Graphical User Interface (GUI)

The tool can be run as simple cross-platform graphical interface (Tkinter).

Launching the GUI

Ways to launch the GUI interface:

  1. Implicit Launch: Run the tool or file with no arguments, subcommands, or flags. (Note: PyInstaller builds use the --windowed (or -noconsole) flag, except for on Termux.)
  2. Explicit Command: Use the dedicated GUI subcommand (pdflinkcheck gui).

🚀 CLI Usage

The core functionality is accessed via the analyze command.

pdflinkcheck --help: Screenshot of the pdflinkcheck CLI Tree Help

See the Help Tree by unlocking the help-tree CLI command, using the DEV_TYPER_HELP_TREE env var.

DEV_TYPER_HELP_TREE=1 pdflinkcheck help-tree` # bash
$env:DEV_TYPER_HELP_TREE = "1"; pdflinkcheck help-tree` # PowerShell

Screenshot of the pdflinkcheck CLI Tree Help

Available Commands

Command Description
pdflinkcheck analyze Analyzes a PDF file for links and validates their reasonableness.
pdflinkcheck gui Explicitly launch the Graphical User Interface.
pdflinkcheck docs Access documentation, including the README and AGPLv3+ license.
pdflinkcheck serve Serve a basic local web app which uses only the Python standard library.
pdflinkcheck tools Access additional tools, like --clear-cache.

analyze Command Options

Option Description Default
<PDF_PATH> Required. The path to the PDF file to analyze. N/A
--pdf-library / -p Select engine: pymupdf or pypdf. pypdf
--export-format / -e Export to JSON, TXT, or None to suppress file output. JSON

gui Command Options

Option Description Default
--auto-close INTEGER (For testing/automation only). Delay in milliseconds after which the GUI window will automatically close. 0 (Disabled)

Example Runs

# Analyze a document, show all links, and save the report as JSON and TXT
pdflinkcheck analyze "TE Maxson WWTF O&M Manual.pdf" --export-format JSON,TXT

# Show the GUI for only a moment, like in a build check
pdflinkcheck gui --auto-close 3000 

# Show both the LICENSE and README.md docs
pdflinkcheck docs --license --readme 

📦 Library Access (Advanced)

For developers importing pdflinkcheck into other Python projects, the core analysis functions are exposed directly in the root namespace. The various analysis_pdf_* functions each use a different library to extract the target PDF's internal TOC, external links, and metadata.

Function Library Description
run_report() pdflinkcheck (Primary function) Performs the full analysis, prints to console, and handles file export.
analyze_pdf_pdfium() pypdfium2 Fast, ~10 mb, Permissively licensed
analyze_pdf_pymupdf() PyMuPDF Fast, ~30 mb, AGPL3+ licensed
analyze_pdf_pypdf() pypdf library Slow, ~2 mb, Permissively licensed

Exanple:

from pdflinkcheck import ( run_report,
                          analyze_pdf_pymupdf, 
                          analyze_pdf_pypdf, 
                          analyze_pdf_pdfium, 
                          )

file = "document1.pdf"
report_data = run_report(file)
links_pymupdf = extract_links_pymupdf(file)
links_pypdf = extract_links_pypdf(file)

✨ Features

  • Active Link Extraction: Identifies and categorizes all programmed links (External URIs, Internal GoTo/Destinations, Remote Jumps).
  • Anchor Text Retrieval: Extracts the visible text corresponding to each link's bounding box.
  • Structural TOC: Extracts the PDF's internal Table of Contents (bookmarks/outline).

🥚 Optional REPL‑Friendly GUI Access (Easter Egg)

For users who prefer exploring tools interactively—especially those coming from MATLAB or other REPL‑first environments—pdflinkcheck includes an optional Easter egg that exposes the GUI launcher directly in the library namespace.

This feature is disabled by default and has no effect on normal imports.

Enabling the Easter Egg

Set the environment variable before importing the library:

import os
os.environ["PDFLINKCHECK_GUI_EASTEREGG"] = "true"

import pdflinkcheck
pdflinkcheck.start_gui()

Accepted values include: true, 1, yes, on (case‑insensitive).

Purpose

This opt‑in behavior is designed to make the library feel welcoming to beginners who are experimenting in a Python REPL for the first time. When enabled, the start_gui() function becomes available at the top level:

pdflinkcheck.start_gui()

If the PDFLINKCHECK_GUI_EASTEREGG environment variable is not set—or if GUI support is unavailable—pdflinkcheck behaves as a normal library with no GUI functions exposed.

Another Easter Egg

DEV_TYPER_HELP_TREE=1 pdflinkcheck help-tree

This help-tree feature has not yet been submitted for inclusion into Typer.


⚠️ Compatibility Notes

Termux Compatibility as a Key Goal

A key goal of City-of-Memphis-Wastewater is to release all software as Termux-compatible.

Termux compatibility is important in the modern age, because Android devices are common among technicians, field engineers, and maintenace staff. Android is the most common operating system in the Global South. We aim to produce stable software that can do the most possible good.

Now pdflinkcheck can run on Termux by using the pypdf engine and the pdfium engine. Benefits:

  • pypdf-only artifacts, to reduce size to about 6% compared to artifacts that include PyMuPDF.
  • Web-stack GUI as an alternative to the Tkinter GUI, which can be run locally on Termux or as a web app.

PDF Library Selection

At long last, PyMuPDF is an optional dependency. All testing comparing pypdf and PyMuPDF has shown identical validation performance. However PyMuPDF is much faster. The benfit of pypdf is small size of packages and cross-platform compatibility. We have recently added a PDFium option, which circumvents the AGPL3+.

Expecte that all binaries and artifacts contain PyMuPDF, unlss they are built on Android. The GUI and CLI interfaces both allow selection of the library; if PyMuPDF is selected but is not available, the user will be warned.

To install the complete version use one of these options:

pip install "pdflinkcheck[mupdf]"
pipx install "pdflinkcheck[pdfium]"
uv tool install "pdflinkcheck[pdfium]"
uv add "pdflinkcheck[pdfium]"

Document Compatibility:

Not all PDF files can be processed successfully. This tool is designed primarily for digitally generated (vector-based) PDFs.

Processing may fail or yield incomplete results for:

  • Scanned PDFs (images of text) that lack an accessible text layer.
  • Encrypted or Password-Protected documents.
  • Malformed or non-standard PDF files.

Run from Source (Developers)

git clone http://github.com/city-of-memphis-wastewater/pdflinkcheck.git
cd pdflinkcheck

# To include the PyMuPDF dependency in the installation:
uv sync --extras full

# On Termux, to not include PyMuPDF:
uv sync

# To include developer depedecies:
uv sync --all-extras --group dev

# Run the CLI
uv run python src/pdflinkcheck/cli.py --help

# Run a basic webapp and Termux-facing browser-based interface
uv run  python -m pdflinkcheck.stdlib_server

📜 License Implications (AGPLv3+)

The AGPL3-or-later is required for binaries of pdflinkcheck which include PyMuPDF, which is licensed under the AGPL3. The source code itself for pdflinkcheck is licensed under the MIT.

The AGPL3-or-later license has significant implications for distribution and network use, particularly for organizations:

  • Source Code Provision: If you distribute this tool (modified or unmodified) to anyone, you must provide the full source code under the same license.
  • Network Interaction (Affero Clause): If you modify this tool and make the modified version available to users over a computer network (e.g., as a web service or backend), you must also offer the source code to those network users.

Before deploying or modifying this tool for organizational use, especially for internal web services or distribution, please ensure compliance with the AGPLv3+ terms.

Because the AGPLv3 is a strong copyleft license, any version of pdflinkcheck that includes AGPL‑licensed components (such as PyMuPDF) must be distributed as a whole under AGPLv3+. This means that for those versions, anyone who distributes the application — or makes a modified version available over a network — must also provide the complete corresponding source code under the same terms.

The source code of pdflinkcheck itself remains licensed under the MIT License; only the distributed binary becomes AGPL‑licensed when PyMuPDF is included.

Links:

Copyright © 2025 George Clayton Bennett

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdflinkcheck-1.2.30.tar.gz (399.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdflinkcheck-1.2.30-py3-none-any.whl (448.5 kB view details)

Uploaded Python 3

File details

Details for the file pdflinkcheck-1.2.30.tar.gz.

File metadata

  • Download URL: pdflinkcheck-1.2.30.tar.gz
  • Upload date:
  • Size: 399.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pdflinkcheck-1.2.30.tar.gz
Algorithm Hash digest
SHA256 6659c1a627849856fe6e1781858d89f85a3807f51963643e5b6e64c7754c0b49
MD5 6def12762292ba99d620a039941a0b0f
BLAKE2b-256 11514aab3db6e2da0c3938d7e713f2b3b3a6dd6ef8242d3f7fd0ff491ec2a492

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdflinkcheck-1.2.30.tar.gz:

Publisher: publish.yml on City-of-Memphis-Wastewater/pdflinkcheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pdflinkcheck-1.2.30-py3-none-any.whl.

File metadata

  • Download URL: pdflinkcheck-1.2.30-py3-none-any.whl
  • Upload date:
  • Size: 448.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pdflinkcheck-1.2.30-py3-none-any.whl
Algorithm Hash digest
SHA256 dffd932103514ed5da5ece70dda501bba448298f2896513cb149ca93e83e414e
MD5 2417d7e1ef61d10116b159d79dd502b8
BLAKE2b-256 b888a05e8ddb6195501baf31bae90e0463d2bed945d47f326b95267e74b54407

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdflinkcheck-1.2.30-py3-none-any.whl:

Publisher: publish.yml on City-of-Memphis-Wastewater/pdflinkcheck

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page