Skip to main content

kogo

Layout-aware PDF diff for revisions — compare an old and new PDF and highlight added or deleted text, figures, and annotations, in the browser and in marked PDFs.

kogo (校合) is the Japanese publishing term for checking a revision against the original.

kogo results

Features

  • Word-level text diff for Latin text, character-level precision for CJK (Chinese, Japanese, Korean) text, including rare kanji across CJK Extensions B-J
  • Reading order reconstructed from whitespace layout, so multi-column pages and slide-style text boxes are compared correctly instead of interleaved
  • Page alignment that tolerates inserted or removed pages, using both text and visual page signatures
  • Visual diff for figures, equations, and layout, with text areas masked out and scanner/export shift registration for image-only pages
  • Detects added or removed highlights, comments, and ink annotations
  • Detects style-only changes (bold, italic, font-size) on otherwise-unchanged text, marked in amber
  • Markers are baked into the output PDFs so they show up in any viewer, even with annotations hidden
  • Selectable-text web preview powered by Mozilla PDF.js
  • Downloadable old-highlighted, new-highlighted, and side-by-side comparison PDFs
  • All processing happens locally — nothing is sent to an external service

Quick start

CLI only

pip install kogo
kogo diff old.pdf new.pdf -o out/

Web app

pip install "kogo[serve]"
kogo fetch-viewer
kogo serve

kogo fetch-viewer downloads the local PDF.js viewer assets used by the web preview (see Configuration); it's not needed with Docker, which bundles them in the image.

Then open http://127.0.0.1:8080.

Docker

docker compose up -d --build

Then open http://localhost:8080. By default the container only binds to 127.0.0.1 (localhost). To share it on a LAN, there is no authentication built in, so only do this on a trusted network:

KOGO_HOST=0.0.0.0 docker compose up -d --build

CLI usage

kogo diff OLD.pdf NEW.pdf \
  -o kogo-diff \
  --dpi 144 \
  --sensitivity standard \
  --max-pages 200

Options:

  • -o, --out — output directory (default kogo-diff)
  • --dpi — rendering resolution for the visual diff, 96–180 (default 144)
  • --sensitivityhigh, standard, or low (default standard)
  • --max-pages — maximum pages per file (default 200)
  • --no-previews — skip generating page preview images
  • --json — print the full result as JSON

kogo serve runs the web application:

kogo serve --host 127.0.0.1 --port 8080

Configuration

The web app reads these environment variables:

Variable Default Description
JOBS_DIR ~/.local/share/kogo/jobs Where uploaded files and comparison results are stored
MAX_UPLOAD_MB 100 Maximum size per uploaded PDF
MAX_PAGES 200 Maximum pages per PDF
JOB_TTL_HOURS 24 How long comparison results are kept before cleanup
MAX_CONCURRENT_JOBS 2 Number of comparisons processed at once
KOGO_VENDOR_DIR ~/.local/share/kogo/vendor/pdfjs Where kogo fetch-viewer installs (and the server looks for) the local PDF.js viewer assets

How it works

Text is extracted at word precision (character precision for CJK) and reordered using recursive whitespace cuts, so columns, slide text boxes, and reflowed paragraphs are read in a sensible order rather than the PDF's raw internal stream order. Pages are aligned across the two documents with a similarity-based sequence alignment (combining text and, for image-heavy pages, visual signatures) so inserted or removed pages don't desynchronize the rest of the comparison. Remaining differences are then diffed with Python's difflib.

Figures, equations, and other non-text layout are compared by rendering each page to an image, masking out the areas already covered by the text diff, and taking a pixel difference. Image-only pages get a small registration step to correct for scanner or export shifts before the pixel diff runs. Existing PDF annotations (highlights, comments, ink) are fingerprinted and diffed separately.

Limitations

  • Scan-only PDFs (no embedded text layer) are compared visually; add an OCR text layer first if you need word-level text diffs
  • Password-protected PDFs are not supported
  • Complex tables and vertical text layouts may need a visual check in addition to the automated diff
  • There is no authentication built in. kogo serve and the default Docker Compose setup only bind to localhost; put the web app behind a reverse proxy with authentication before exposing it to anything beyond your local machine or trusted LAN

Development

python -m unittest discover -s tests -v

License

kogo is licensed under AGPL-3.0. See LICENSE.

Copyright (C) 2026 ta-061. Released under the GNU Affero General Public License v3.0 (AGPL-3.0-only).

PyMuPDF (and the underlying MuPDF library) is distributed under AGPL-3.0-or-commercial; check its license terms before redistributing kogo or offering it as a network service.

If you modify kogo and let others use it over a network (for example, by self-hosting a modified version of the web app), AGPL-3.0 §13 requires you to offer those users the corresponding source code. The "Source code" link in the web app's footer is where self-hosters should point to their source.

Credits:

Download files

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

Source Distribution

kogo-0.1.0.tar.gz (59.6 kB view details)

Uploaded Source

Built Distribution

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

kogo-0.1.0-py3-none-any.whl (56.1 kB view details)

Uploaded Python 3

File details

Details for the file kogo-0.1.0.tar.gz.

File metadata

  • Download URL: kogo-0.1.0.tar.gz
  • Upload date:
  • Size: 59.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for kogo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e55689fa53b8f2fdc17c8b5503308952fee00f7e17bf4561128ad758a6c9c77
MD5 426f6c447e1087ec5353c20ba596065a
BLAKE2b-256 ccadb979836658d2b95e03253a292cafaf714fa359f2ae94b5f5dd3779b8392b

See more details on using hashes here.

Provenance

The following attestation bundles were made for kogo-0.1.0.tar.gz:

Publisher: publish.yml on ta-061/kogo

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

File details

Details for the file kogo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kogo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 56.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for kogo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bcb10b4002916e5e521cc4c20ea3048bc3147197fc7771979994a14451148816
MD5 4a8c0ed13566fa61414712e1001b60bd
BLAKE2b-256 06933d53fee026528beae8618e0e235823513a8164d8e4aa0837c7f4f521dc61

See more details on using hashes here.

Provenance

The following attestation bundles were made for kogo-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ta-061/kogo

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

Release history Release notifications | RSS feed

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

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