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 link remnants within PDF documents, primarily using the PyMuPDF 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.

🚀 Recommended Access (Binary Files)

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, .pyz) GUI (Double-Click) Double-click the file (use the accompanying .bat file on Windows).
PYZ (Python Zip App) CLI (Terminal) Run using your system's python command: python pdflinkcheck-VERSION.pyz analyze ...

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

💻 Graphical User Interface (GUI)

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

Launching the GUI

There are three ways to launch the GUI interface:

  1. Implicit Launch: Run the main command with no arguments, subcommands, or flags (pdflinkcheck).
  2. Explicit Command: Use the dedicated GUI subcommand (pdflinkcheck gui).
  3. Binary Double-Click:
    • Windows: Double-click the pdflinkcheck-VERSION-gui.bat file.
    • macOS/Linux: Double-click the downloaded .pyz or .elf file.

Planned GUI Updates

We are actively working on the following enhancements:

  • Report Export: Functionality to export the full analysis report to a plain text file.
  • License Visibility: A dedicated "License Info" button within the GUI to display the terms of the AGPLv3+ license.

🚀 CLI Usage

The core functionality is accessed via the analyze command. All commands include the built-in --help flag for quick reference.

Available Commands

Command Description
pdflinkcheck analyze Analyzes a PDF file for links and remnants.
pdflinkcheck gui Explicitly launch the Graphical User Interface.
pdflinkcheck license Displays the full AGPLv3+ license text in the terminal.

analyze Command Options

Option Description Default
<PDF_PATH> Required. The path to the PDF file to analyze. N/A
--check-remnants / --no-check-remnants Toggle scanning the text layer for unlinked URLs/Emails. --check-remnants
--max-links INTEGER Maximum number of links/remnants to display in the detailed report sections. Use 0 to show all. 0 (Show All)
--export-format FORMAT Format for the exported report. If specified, the report is saved to a file named after the PDF. Currently supported: JSON. JSON
--help Show command help and exit. N/A

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/remnants, and save the report as JSON
pdflinkcheck analyze "TE Maxson WWTF O&M Manual.pdf" --export-format JSON

# Analyze a document but skip the time-consuming remnant check
pdflinkcheck analyze "another_doc.pdf" --no-check-remnants 

# Analyze a document but keep the print block short, showing only the first 10 links for each type
pdflinkcheck analyze "TE Maxson WWTF O&M Manual.pdf" --max-links 10

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

📦 Library Access (Advanced)

For developers importing pdflinkcheck into other Python projects, the core analysis functions are exposed directly in the root namespace:

Function Description
run_analysis() (Primary function) Performs the full analysis, prints to console, and handles file export.
extract_links() Low-level function to retrieve all explicit links (URIs, GoTo, etc.) from a PDF path.
extract_toc() Low-level function to extract the PDF's internal Table of Contents (bookmarks/outline).

Python

from pdflinkcheck.analyze import run_analysis, extract_links, extract_toc

✨ 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.
  • Remnant Detection: Scans the document's text layer for unlinked URIs and email addresses that should potentially be converted into active links.
  • Structural TOC: Extracts the PDF's internal Table of Contents (bookmarks/outline).

📜 License Implications (AGPLv3+)

pdflinkcheck is licensed under the GNU Affero General Public License version 3 or later (AGPLv3+).

This 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.


🥚 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.


⚠️ Compatibility Notes

Platform Compatibility:

This tool relies on the PyMuPDF library. All testing has failed to run in a Termux (Android) environment due to underlying C/C++ library compilation issues with PyMuPDF. It is recommended for use on standard Linux, macOS, or Windows operating systems.

Termux Compatibility as a Key Goal

A key goal of City-of-Memphis-Wastewater is to release all software as Termux-compatible. Unfortunately, that simply isn't possible with PyMuPDF as a dependency. We tried alternative PDF libaries like pdfminer, pdfplumber, and borb, but none of these offered the level of detail concerning GoTo links. Due to Termux compatibility goals, we do not generally make Tkinter-based interfaces, so that was a fun, minimalist opportunity on this project.

Termux compatibility is important in the modern age as 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.

We love web-stack GUIs served locally as a final product. All that packaged up into a Termux-compatible ELF or PYZ - What could be better!

In the future we may find a work-around and be able to drop the PyMuPDF dependency. This would have lots of implications:

  • Reduced artifact size.
  • Alpine-compatible Docker image.
  • Web-stack GUI rather than Tkinter, to be compatible with Termux.
  • A different license from the AGPL3, if we choose at that time.

In the meantime, the standalone binaries and pipx installation provide excellent cross-platform support on Windows, macOS, and standard Linux desktops/laptops.

Document Compatibility:

While pdflinkcheck uses the robust PyMuPDF library, 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
uv sync
uv run python src/pdflinkcheck/cli.py --help

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.1.49.tar.gz (50.2 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.1.49-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pdflinkcheck-1.1.49.tar.gz
Algorithm Hash digest
SHA256 069f65b705c75fea11785d5fa64c46d1f100b088b4c11a9f61ce878f29e97988
MD5 6ac38f24592988965c299512bdde0cc1
BLAKE2b-256 273e1f41fdf09a3de18536a8592bf6b7867a1ed355d1f57a8d3f5b54b78082cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdflinkcheck-1.1.49.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.1.49-py3-none-any.whl.

File metadata

  • Download URL: pdflinkcheck-1.1.49-py3-none-any.whl
  • Upload date:
  • Size: 47.8 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.1.49-py3-none-any.whl
Algorithm Hash digest
SHA256 49b7c0446e486b0cb6c5bc48fa79866982702c0386892c60260d91e1f5b46676
MD5 c900a33d16e2ba6355741d1a08b1f6a3
BLAKE2b-256 871a63d70d1528de268322816cfa819d568cd434bb130415196924c454e91e2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdflinkcheck-1.1.49-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