lynkeus 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lynkeus-0.1.1/LICENSE +21 -0
- lynkeus-0.1.1/PKG-INFO +232 -0
- lynkeus-0.1.1/README.md +214 -0
- lynkeus-0.1.1/pyproject.toml +35 -0
- lynkeus-0.1.1/pyproject.toml.orig +29 -0
- lynkeus-0.1.1/src/lynkeus/__init__.py +880 -0
- lynkeus-0.1.1/src/lynkeus/__main__.py +7 -0
lynkeus-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pierre Wilke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
lynkeus-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lynkeus
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Summarize the differences between two PDF files: hashes, then text, then pixels
|
|
5
|
+
Keywords: pdf,diff,compare,visual diff,report
|
|
6
|
+
Author: Pierre Wilke
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: Operating System :: POSIX
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Text Processing
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# lynkeus
|
|
20
|
+
|
|
21
|
+
Summarize the differences between two PDF files: are they the same, did only
|
|
22
|
+
the metadata change, which pages changed their text, and which changed only
|
|
23
|
+
visually.
|
|
24
|
+
|
|
25
|
+
```console
|
|
26
|
+
$ lynkeus latex-article/base.pdf stamp/filled.pdf -o report/
|
|
27
|
+
== 1. hashes
|
|
28
|
+
A: latex-article/base.pdf
|
|
29
|
+
sha1 3cbca933ea700e39010c46ee4fe065adf31e5e03
|
|
30
|
+
sha256 0c5a8905f55047648f10893beefc8ae05388a50f492307904db922f017141975
|
|
31
|
+
B: stamp/filled.pdf
|
|
32
|
+
sha1 0b7c83be87bd32ade4936c9820b1bd53e9d257bc
|
|
33
|
+
sha256 518e9db4ffba1acf97aaf9e02f97f4ed29c71184fea79d008090d66b9221cfd2
|
|
34
|
+
raw hashes differ
|
|
35
|
+
file size: 116,618 → 125,415 bytes
|
|
36
|
+
normalized hash differs: content changed
|
|
37
|
+
|
|
38
|
+
== 2. text (5 vs 5 pages)
|
|
39
|
+
page 1: +3/−0 words (2 changes, similarity 97%)
|
|
40
|
+
thing. Participant form Name: {+Jane Doe+} Date: □ I agree
|
|
41
|
+
Participant form Name: Date: {+04/12/2026+} □ I agree to
|
|
42
|
+
|
|
43
|
+
== 3. visual (dpi 60, fuzz 10%, threshold 4 px)
|
|
44
|
+
visual-only changes (text identical): 5
|
|
45
|
+
page 5: 0.08% of pixels
|
|
46
|
+
text + visual changes: 1
|
|
47
|
+
|
|
48
|
+
== summary
|
|
49
|
+
5 aligned pages, 3 unchanged, 1 text changes, 1 visual-only
|
|
50
|
+
|
|
51
|
+
report: report/report.html
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Here a form was filled in on page 1 (a name and a date: text changes) and a
|
|
55
|
+
signature image pasted on page 5 (no text: a visual-only change). Both PDFs
|
|
56
|
+
come from the [examples](#examples-and-tests) (`make`, then look in `build/`).
|
|
57
|
+
|
|
58
|
+
## The name
|
|
59
|
+
|
|
60
|
+
Lynkeus (Λυγκεύς, Lynceus in Latin) was the Argonaut with the sharpest eyes in
|
|
61
|
+
Greek myth. He could see through tree trunks, walls and rock, and spot things
|
|
62
|
+
from very far away. Pindar tells how, from the top of Mount Taygetus, he
|
|
63
|
+
spotted Castor hiding inside a hollow oak. His name became a byword for
|
|
64
|
+
sharp sight ("lynx-eyed"), and Goethe made him the tower watchman of
|
|
65
|
+
*Faust II*, "born to see, appointed to watch".
|
|
66
|
+
|
|
67
|
+
That's the job here: look through the surface of two PDFs (bytes, metadata,
|
|
68
|
+
text) and spot even the smallest visual change: a ticked box, a signature,
|
|
69
|
+
a page number that moved.
|
|
70
|
+
|
|
71
|
+
## How it works
|
|
72
|
+
|
|
73
|
+
The checks run from cheapest to most expensive, and stop as soon as the
|
|
74
|
+
answer is known:
|
|
75
|
+
|
|
76
|
+
1. **Hashes.** SHA-1 and SHA-256 of both files. If they differ, a
|
|
77
|
+
*normalized* hash is computed: the file is rewritten by qpdf in a fixed
|
|
78
|
+
form, and dates, IDs, producer and XMP metadata are removed. Equal
|
|
79
|
+
normalized hashes mean "same content, only metadata differs", and the
|
|
80
|
+
metadata fields that changed are listed.
|
|
81
|
+
2. **Text.** The text of each page is extracted (`pdftotext`) and normalized
|
|
82
|
+
(Unicode NFKC, invisible characters and line-end hyphenation removed).
|
|
83
|
+
Pages are matched by similarity, so an inserted or deleted page is
|
|
84
|
+
reported as such instead of shifting every later page. Changed pages get
|
|
85
|
+
a word count and word-level snippets. Pages with the same words in a
|
|
86
|
+
different order (common with math and tables) are reported separately.
|
|
87
|
+
3. **Visual.** Matched pages are rendered (`pdftoppm`) and compared pixel by
|
|
88
|
+
pixel (ImageMagick `compare`, with a colour tolerance). A page counts as
|
|
89
|
+
visually changed when at least `--min-pixels` pixels differ. Pages whose
|
|
90
|
+
text is identical but whose pixels differ are listed as **visual-only**:
|
|
91
|
+
usually a figure, a font or layout change, or something pasted on top.
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
lynkeus is a Python package with a `lynkeus` command. Once it is published on
|
|
96
|
+
PyPI:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
uv tool install lynkeus # or: pipx install lynkeus
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
From a checkout of this repository:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
uv tool install . # installs the `lynkeus` command
|
|
106
|
+
uv run lynkeus A.pdf B.pdf # or run it in place, without installing
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
It also needs a few programs that pip and uv can't install: see
|
|
110
|
+
[Dependencies](#dependencies).
|
|
111
|
+
|
|
112
|
+
## Dependencies
|
|
113
|
+
|
|
114
|
+
### Python
|
|
115
|
+
|
|
116
|
+
Python 3.10 or newer. lynkeus uses only the standard library: the
|
|
117
|
+
`dependencies` list in `pyproject.toml` is empty.
|
|
118
|
+
|
|
119
|
+
### Programs lynkeus runs
|
|
120
|
+
|
|
121
|
+
| Program | Package (Debian/Ubuntu) | Used for | Tested with |
|
|
122
|
+
|---|---|---|---|
|
|
123
|
+
| `pdftotext`, `pdftoppm`, `pdfinfo` | `poppler-utils` | text extraction, page rendering, metadata | 25.03 |
|
|
124
|
+
| `qpdf` | `qpdf` | normalized hash (stage 1) | 12.2 |
|
|
125
|
+
| `magick` | `imagemagick` (version 7) | pixel comparison, change marks and image compression in the report | 7.1.2 |
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
sudo apt install poppler-utils qpdf imagemagick
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
ImageMagick 7 is needed: lynkeus calls the `magick` command, which
|
|
132
|
+
ImageMagick 6 doesn't provide. With `--no-visual` and without `-o`,
|
|
133
|
+
ImageMagick isn't used at all.
|
|
134
|
+
|
|
135
|
+
### Additionally, for the examples and tests
|
|
136
|
+
|
|
137
|
+
| Program | Package (Debian/Ubuntu) | Used for |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| `make`, `bash`, `awk`, `sed`, `grep` | `make`, base system | the test suite |
|
|
140
|
+
| `uv` | [docs.astral.sh/uv](https://docs.astral.sh/uv/) | runs lynkeus from the checkout |
|
|
141
|
+
| `pdflatex` with beamer | `texlive-latex-base`, `texlive-latex-recommended`, `cm-super` | LaTeX examples |
|
|
142
|
+
| `typst` 0.13 or newer (tested with 0.15.1) | [typst.app](https://github.com/typst/typst) (e.g. `cargo install typst-cli`) | Typst examples and the stamp overlays |
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
sudo apt install make texlive-latex-base texlive-latex-recommended cm-super
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The Typst slides use the public [polylux](https://typst.app/universe/package/polylux)
|
|
149
|
+
package, which Typst downloads on the first build. The Typst examples use only
|
|
150
|
+
Typst's built-in fonts, so they need no font installed.
|
|
151
|
+
|
|
152
|
+
## Usage
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
lynkeus A.pdf B.pdf [options]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`python -m lynkeus` works too.
|
|
159
|
+
|
|
160
|
+
| Option | Default | Meaning |
|
|
161
|
+
|---|---|---|
|
|
162
|
+
| `-o DIR`, `--out DIR` | | write an HTML report (`DIR/report.html`) with page images |
|
|
163
|
+
| `--dpi N` | 60 | render resolution for the visual comparison |
|
|
164
|
+
| `--fuzz P` | 10 | per-pixel colour tolerance, in % |
|
|
165
|
+
| `--min-pixels N` | 4 | a page counts as visually changed from N differing pixels |
|
|
166
|
+
| `--zoom-dpi N` | 120 | resolution of the zoomable images in the report |
|
|
167
|
+
| `--colors N` | 64 | palette size of the report images (`0` keeps full colour) |
|
|
168
|
+
| `--no-visual` | | skip stage 3 (faster, text only) |
|
|
169
|
+
| `-v`, `--verbose` | | show every word-level change, not only the first two per page |
|
|
170
|
+
|
|
171
|
+
**Exit status**, as with `diff`: `0` when the content is the same (identical
|
|
172
|
+
bytes, or only the metadata differs), `1` when it differs, `2` on error.
|
|
173
|
+
|
|
174
|
+
### The HTML report
|
|
175
|
+
|
|
176
|
+
With `-o`, lynkeus writes `report.html` and its images to the given folder:
|
|
177
|
+
|
|
178
|
+
- a header that stays visible while scrolling, with both file names and
|
|
179
|
+
their SHA-1;
|
|
180
|
+
- filters by kind of change: text, reordered, visual-only, added, removed,
|
|
181
|
+
and unchanged (off by default);
|
|
182
|
+
- for each page, the old page, a diff image and the new page side by side,
|
|
183
|
+
with the changed words highlighted;
|
|
184
|
+
- click any image to open a full-screen viewer: both versions side by side,
|
|
185
|
+
zoom (mouse wheel, `+`/`−`, double-click) and pan (drag) kept in sync,
|
|
186
|
+
red marks over the changed areas (`m`), an optional diff pane (`d`), and
|
|
187
|
+
`←`/`→` to move between pages.
|
|
188
|
+
|
|
189
|
+
When the comparison stops at stage 1, the report shows the verdict and, for
|
|
190
|
+
metadata-only changes, a table of the fields that differ.
|
|
191
|
+
|
|
192
|
+
## Examples and tests
|
|
193
|
+
|
|
194
|
+
`examples/` contains test documents that each change one thing at a time:
|
|
195
|
+
|
|
196
|
+
- `latex-article/`, `latex-beamer/`: LaTeX article and beamer slides
|
|
197
|
+
- `typst-document/`, `typst-slides/`: a plain Typst document, and slides made
|
|
198
|
+
with [polylux](https://typst.app/universe/package/polylux)
|
|
199
|
+
- `stamp/`: a signature, and a filled-in form, pasted onto an existing PDF
|
|
200
|
+
with a transparent Typst overlay and `qpdf --overlay`
|
|
201
|
+
|
|
202
|
+
Each document is a single source with variants chosen at build time: `base`,
|
|
203
|
+
`meta` (same content, different timestamp), `text`, `addpage`, `rmpage`,
|
|
204
|
+
`addimg` and `chgimg`.
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
make # build every example PDF into build/
|
|
208
|
+
make -j8 test # build, then run the checks in examples/tests.tsv
|
|
209
|
+
make retest # run every check again
|
|
210
|
+
make clean # remove build/
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Each line of `examples/tests.tsv` names two PDFs, the expected exit code, and
|
|
214
|
+
strings lynkeus's output must (or, with a `!` prefix, must not) contain.
|
|
215
|
+
`make test` writes an HTML report for every check and an index at
|
|
216
|
+
`build/reports/index.html`, with each check's status and verdict.
|
|
217
|
+
|
|
218
|
+
The checks run lynkeus from the checkout with `uv run lynkeus`. To test
|
|
219
|
+
another command instead, for example an installed one, set `LYNKEUS`:
|
|
220
|
+
`make test LYNKEUS=lynkeus`.
|
|
221
|
+
|
|
222
|
+
## Known limitations
|
|
223
|
+
|
|
224
|
+
- **Page numbers.** After a page is added or removed, every page whose number
|
|
225
|
+
or page total changed shows a small text change (`+1/−1 words`).
|
|
226
|
+
- **Very small glyphs.** At the default 60 dpi, a change in a tiny footer
|
|
227
|
+
(for example a page total going from "1/6" to "1/7") can touch fewer
|
|
228
|
+
pixels than the threshold. The text stage still reports it.
|
|
229
|
+
- **Text extraction.** If the PDF producer changes how it encodes text,
|
|
230
|
+
the text stage can report changes that aren't visible, for example an
|
|
231
|
+
emoji drawn as an image instead of a glyph, or math extracted in a
|
|
232
|
+
different order. Check the visual stage for those pages.
|
lynkeus-0.1.1/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# lynkeus
|
|
2
|
+
|
|
3
|
+
Summarize the differences between two PDF files: are they the same, did only
|
|
4
|
+
the metadata change, which pages changed their text, and which changed only
|
|
5
|
+
visually.
|
|
6
|
+
|
|
7
|
+
```console
|
|
8
|
+
$ lynkeus latex-article/base.pdf stamp/filled.pdf -o report/
|
|
9
|
+
== 1. hashes
|
|
10
|
+
A: latex-article/base.pdf
|
|
11
|
+
sha1 3cbca933ea700e39010c46ee4fe065adf31e5e03
|
|
12
|
+
sha256 0c5a8905f55047648f10893beefc8ae05388a50f492307904db922f017141975
|
|
13
|
+
B: stamp/filled.pdf
|
|
14
|
+
sha1 0b7c83be87bd32ade4936c9820b1bd53e9d257bc
|
|
15
|
+
sha256 518e9db4ffba1acf97aaf9e02f97f4ed29c71184fea79d008090d66b9221cfd2
|
|
16
|
+
raw hashes differ
|
|
17
|
+
file size: 116,618 → 125,415 bytes
|
|
18
|
+
normalized hash differs: content changed
|
|
19
|
+
|
|
20
|
+
== 2. text (5 vs 5 pages)
|
|
21
|
+
page 1: +3/−0 words (2 changes, similarity 97%)
|
|
22
|
+
thing. Participant form Name: {+Jane Doe+} Date: □ I agree
|
|
23
|
+
Participant form Name: Date: {+04/12/2026+} □ I agree to
|
|
24
|
+
|
|
25
|
+
== 3. visual (dpi 60, fuzz 10%, threshold 4 px)
|
|
26
|
+
visual-only changes (text identical): 5
|
|
27
|
+
page 5: 0.08% of pixels
|
|
28
|
+
text + visual changes: 1
|
|
29
|
+
|
|
30
|
+
== summary
|
|
31
|
+
5 aligned pages, 3 unchanged, 1 text changes, 1 visual-only
|
|
32
|
+
|
|
33
|
+
report: report/report.html
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Here a form was filled in on page 1 (a name and a date: text changes) and a
|
|
37
|
+
signature image pasted on page 5 (no text: a visual-only change). Both PDFs
|
|
38
|
+
come from the [examples](#examples-and-tests) (`make`, then look in `build/`).
|
|
39
|
+
|
|
40
|
+
## The name
|
|
41
|
+
|
|
42
|
+
Lynkeus (Λυγκεύς, Lynceus in Latin) was the Argonaut with the sharpest eyes in
|
|
43
|
+
Greek myth. He could see through tree trunks, walls and rock, and spot things
|
|
44
|
+
from very far away. Pindar tells how, from the top of Mount Taygetus, he
|
|
45
|
+
spotted Castor hiding inside a hollow oak. His name became a byword for
|
|
46
|
+
sharp sight ("lynx-eyed"), and Goethe made him the tower watchman of
|
|
47
|
+
*Faust II*, "born to see, appointed to watch".
|
|
48
|
+
|
|
49
|
+
That's the job here: look through the surface of two PDFs (bytes, metadata,
|
|
50
|
+
text) and spot even the smallest visual change: a ticked box, a signature,
|
|
51
|
+
a page number that moved.
|
|
52
|
+
|
|
53
|
+
## How it works
|
|
54
|
+
|
|
55
|
+
The checks run from cheapest to most expensive, and stop as soon as the
|
|
56
|
+
answer is known:
|
|
57
|
+
|
|
58
|
+
1. **Hashes.** SHA-1 and SHA-256 of both files. If they differ, a
|
|
59
|
+
*normalized* hash is computed: the file is rewritten by qpdf in a fixed
|
|
60
|
+
form, and dates, IDs, producer and XMP metadata are removed. Equal
|
|
61
|
+
normalized hashes mean "same content, only metadata differs", and the
|
|
62
|
+
metadata fields that changed are listed.
|
|
63
|
+
2. **Text.** The text of each page is extracted (`pdftotext`) and normalized
|
|
64
|
+
(Unicode NFKC, invisible characters and line-end hyphenation removed).
|
|
65
|
+
Pages are matched by similarity, so an inserted or deleted page is
|
|
66
|
+
reported as such instead of shifting every later page. Changed pages get
|
|
67
|
+
a word count and word-level snippets. Pages with the same words in a
|
|
68
|
+
different order (common with math and tables) are reported separately.
|
|
69
|
+
3. **Visual.** Matched pages are rendered (`pdftoppm`) and compared pixel by
|
|
70
|
+
pixel (ImageMagick `compare`, with a colour tolerance). A page counts as
|
|
71
|
+
visually changed when at least `--min-pixels` pixels differ. Pages whose
|
|
72
|
+
text is identical but whose pixels differ are listed as **visual-only**:
|
|
73
|
+
usually a figure, a font or layout change, or something pasted on top.
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
lynkeus is a Python package with a `lynkeus` command. Once it is published on
|
|
78
|
+
PyPI:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
uv tool install lynkeus # or: pipx install lynkeus
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
From a checkout of this repository:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
uv tool install . # installs the `lynkeus` command
|
|
88
|
+
uv run lynkeus A.pdf B.pdf # or run it in place, without installing
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
It also needs a few programs that pip and uv can't install: see
|
|
92
|
+
[Dependencies](#dependencies).
|
|
93
|
+
|
|
94
|
+
## Dependencies
|
|
95
|
+
|
|
96
|
+
### Python
|
|
97
|
+
|
|
98
|
+
Python 3.10 or newer. lynkeus uses only the standard library: the
|
|
99
|
+
`dependencies` list in `pyproject.toml` is empty.
|
|
100
|
+
|
|
101
|
+
### Programs lynkeus runs
|
|
102
|
+
|
|
103
|
+
| Program | Package (Debian/Ubuntu) | Used for | Tested with |
|
|
104
|
+
|---|---|---|---|
|
|
105
|
+
| `pdftotext`, `pdftoppm`, `pdfinfo` | `poppler-utils` | text extraction, page rendering, metadata | 25.03 |
|
|
106
|
+
| `qpdf` | `qpdf` | normalized hash (stage 1) | 12.2 |
|
|
107
|
+
| `magick` | `imagemagick` (version 7) | pixel comparison, change marks and image compression in the report | 7.1.2 |
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
sudo apt install poppler-utils qpdf imagemagick
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
ImageMagick 7 is needed: lynkeus calls the `magick` command, which
|
|
114
|
+
ImageMagick 6 doesn't provide. With `--no-visual` and without `-o`,
|
|
115
|
+
ImageMagick isn't used at all.
|
|
116
|
+
|
|
117
|
+
### Additionally, for the examples and tests
|
|
118
|
+
|
|
119
|
+
| Program | Package (Debian/Ubuntu) | Used for |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `make`, `bash`, `awk`, `sed`, `grep` | `make`, base system | the test suite |
|
|
122
|
+
| `uv` | [docs.astral.sh/uv](https://docs.astral.sh/uv/) | runs lynkeus from the checkout |
|
|
123
|
+
| `pdflatex` with beamer | `texlive-latex-base`, `texlive-latex-recommended`, `cm-super` | LaTeX examples |
|
|
124
|
+
| `typst` 0.13 or newer (tested with 0.15.1) | [typst.app](https://github.com/typst/typst) (e.g. `cargo install typst-cli`) | Typst examples and the stamp overlays |
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
sudo apt install make texlive-latex-base texlive-latex-recommended cm-super
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The Typst slides use the public [polylux](https://typst.app/universe/package/polylux)
|
|
131
|
+
package, which Typst downloads on the first build. The Typst examples use only
|
|
132
|
+
Typst's built-in fonts, so they need no font installed.
|
|
133
|
+
|
|
134
|
+
## Usage
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
lynkeus A.pdf B.pdf [options]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`python -m lynkeus` works too.
|
|
141
|
+
|
|
142
|
+
| Option | Default | Meaning |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| `-o DIR`, `--out DIR` | | write an HTML report (`DIR/report.html`) with page images |
|
|
145
|
+
| `--dpi N` | 60 | render resolution for the visual comparison |
|
|
146
|
+
| `--fuzz P` | 10 | per-pixel colour tolerance, in % |
|
|
147
|
+
| `--min-pixels N` | 4 | a page counts as visually changed from N differing pixels |
|
|
148
|
+
| `--zoom-dpi N` | 120 | resolution of the zoomable images in the report |
|
|
149
|
+
| `--colors N` | 64 | palette size of the report images (`0` keeps full colour) |
|
|
150
|
+
| `--no-visual` | | skip stage 3 (faster, text only) |
|
|
151
|
+
| `-v`, `--verbose` | | show every word-level change, not only the first two per page |
|
|
152
|
+
|
|
153
|
+
**Exit status**, as with `diff`: `0` when the content is the same (identical
|
|
154
|
+
bytes, or only the metadata differs), `1` when it differs, `2` on error.
|
|
155
|
+
|
|
156
|
+
### The HTML report
|
|
157
|
+
|
|
158
|
+
With `-o`, lynkeus writes `report.html` and its images to the given folder:
|
|
159
|
+
|
|
160
|
+
- a header that stays visible while scrolling, with both file names and
|
|
161
|
+
their SHA-1;
|
|
162
|
+
- filters by kind of change: text, reordered, visual-only, added, removed,
|
|
163
|
+
and unchanged (off by default);
|
|
164
|
+
- for each page, the old page, a diff image and the new page side by side,
|
|
165
|
+
with the changed words highlighted;
|
|
166
|
+
- click any image to open a full-screen viewer: both versions side by side,
|
|
167
|
+
zoom (mouse wheel, `+`/`−`, double-click) and pan (drag) kept in sync,
|
|
168
|
+
red marks over the changed areas (`m`), an optional diff pane (`d`), and
|
|
169
|
+
`←`/`→` to move between pages.
|
|
170
|
+
|
|
171
|
+
When the comparison stops at stage 1, the report shows the verdict and, for
|
|
172
|
+
metadata-only changes, a table of the fields that differ.
|
|
173
|
+
|
|
174
|
+
## Examples and tests
|
|
175
|
+
|
|
176
|
+
`examples/` contains test documents that each change one thing at a time:
|
|
177
|
+
|
|
178
|
+
- `latex-article/`, `latex-beamer/`: LaTeX article and beamer slides
|
|
179
|
+
- `typst-document/`, `typst-slides/`: a plain Typst document, and slides made
|
|
180
|
+
with [polylux](https://typst.app/universe/package/polylux)
|
|
181
|
+
- `stamp/`: a signature, and a filled-in form, pasted onto an existing PDF
|
|
182
|
+
with a transparent Typst overlay and `qpdf --overlay`
|
|
183
|
+
|
|
184
|
+
Each document is a single source with variants chosen at build time: `base`,
|
|
185
|
+
`meta` (same content, different timestamp), `text`, `addpage`, `rmpage`,
|
|
186
|
+
`addimg` and `chgimg`.
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
make # build every example PDF into build/
|
|
190
|
+
make -j8 test # build, then run the checks in examples/tests.tsv
|
|
191
|
+
make retest # run every check again
|
|
192
|
+
make clean # remove build/
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Each line of `examples/tests.tsv` names two PDFs, the expected exit code, and
|
|
196
|
+
strings lynkeus's output must (or, with a `!` prefix, must not) contain.
|
|
197
|
+
`make test` writes an HTML report for every check and an index at
|
|
198
|
+
`build/reports/index.html`, with each check's status and verdict.
|
|
199
|
+
|
|
200
|
+
The checks run lynkeus from the checkout with `uv run lynkeus`. To test
|
|
201
|
+
another command instead, for example an installed one, set `LYNKEUS`:
|
|
202
|
+
`make test LYNKEUS=lynkeus`.
|
|
203
|
+
|
|
204
|
+
## Known limitations
|
|
205
|
+
|
|
206
|
+
- **Page numbers.** After a page is added or removed, every page whose number
|
|
207
|
+
or page total changed shows a small text change (`+1/−1 words`).
|
|
208
|
+
- **Very small glyphs.** At the default 60 dpi, a change in a tiny footer
|
|
209
|
+
(for example a page total going from "1/6" to "1/7") can touch fewer
|
|
210
|
+
pixels than the threshold. The text stage still reports it.
|
|
211
|
+
- **Text extraction.** If the PDF producer changes how it encodes text,
|
|
212
|
+
the text stage can report changes that aren't visible, for example an
|
|
213
|
+
emoji drawn as an image instead of a glyph, or math extracted in a
|
|
214
|
+
different order. Check the visual stage for those pages.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.13.12,<0.14"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lynkeus"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Summarize the differences between two PDF files: hashes, then text, then pixels"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
keywords = [
|
|
14
|
+
"pdf",
|
|
15
|
+
"diff",
|
|
16
|
+
"compare",
|
|
17
|
+
"visual diff",
|
|
18
|
+
"report",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Environment :: Console",
|
|
23
|
+
"Intended Audience :: End Users/Desktop",
|
|
24
|
+
"Operating System :: POSIX",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Topic :: Text Processing",
|
|
27
|
+
"Topic :: Utilities",
|
|
28
|
+
]
|
|
29
|
+
dependencies = []
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Pierre Wilke"
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
lynkeus = "lynkeus:main"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.13.12,<0.14"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lynkeus"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Summarize the differences between two PDF files: hashes, then text, then pixels"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Pierre Wilke" }]
|
|
14
|
+
keywords = ["pdf", "diff", "compare", "visual diff", "report"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: End Users/Desktop",
|
|
19
|
+
"Operating System :: POSIX",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Topic :: Text Processing",
|
|
22
|
+
"Topic :: Utilities",
|
|
23
|
+
]
|
|
24
|
+
# No Python dependencies. The external programs it runs (poppler-utils,
|
|
25
|
+
# qpdf, ImageMagick 7) can't be installed by pip: see README.md.
|
|
26
|
+
dependencies = []
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
lynkeus = "lynkeus:main"
|