diffpdf 1.1.1__tar.gz → 1.2.0__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.
Files changed (40) hide show
  1. {diffpdf-1.1.1 → diffpdf-1.2.0}/PKG-INFO +10 -2
  2. {diffpdf-1.1.1 → diffpdf-1.2.0}/README.md +9 -0
  3. {diffpdf-1.1.1 → diffpdf-1.2.0}/pyproject.toml +2 -1
  4. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/__init__.py +7 -3
  5. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/cli.py +9 -1
  6. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/test_api.py +18 -0
  7. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/test_cli.py +13 -0
  8. diffpdf-1.2.0/uv.lock +865 -0
  9. diffpdf-1.1.1/uv.lock +0 -845
  10. {diffpdf-1.1.1 → diffpdf-1.2.0}/.github/dependabot.yml +0 -0
  11. {diffpdf-1.1.1 → diffpdf-1.2.0}/.github/workflows/build.yml +0 -0
  12. {diffpdf-1.1.1 → diffpdf-1.2.0}/.github/workflows/pypi-publish.yml +0 -0
  13. {diffpdf-1.1.1 → diffpdf-1.2.0}/.gitignore +0 -0
  14. {diffpdf-1.1.1 → diffpdf-1.2.0}/.pre-commit-config.yaml +0 -0
  15. {diffpdf-1.1.1 → diffpdf-1.2.0}/.vscode/extensions.json +0 -0
  16. {diffpdf-1.1.1 → diffpdf-1.2.0}/.vscode/settings.json +0 -0
  17. {diffpdf-1.1.1 → diffpdf-1.2.0}/LICENSE +0 -0
  18. {diffpdf-1.1.1 → diffpdf-1.2.0}/MANIFEST.in +0 -0
  19. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/hash_check.py +0 -0
  20. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/logger.py +0 -0
  21. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/page_check.py +0 -0
  22. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/py.typed +0 -0
  23. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/text_check.py +0 -0
  24. {diffpdf-1.1.1 → diffpdf-1.2.0}/src/diffpdf/visual_check.py +0 -0
  25. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/1-letter-diff-A.pdf +0 -0
  26. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/1-letter-diff-B.pdf +0 -0
  27. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/major-color-diff-A.pdf +0 -0
  28. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/major-color-diff-B.pdf +0 -0
  29. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/page-count-diff-A.pdf +0 -0
  30. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/page-count-diff-B.pdf +0 -0
  31. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/unicode-A.pdf +0 -0
  32. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/fail/unicode-B.pdf +0 -0
  33. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/hash-diff-A.pdf +0 -0
  34. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/hash-diff-B.pdf +0 -0
  35. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/identical-A.pdf +0 -0
  36. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/identical-B.pdf +0 -0
  37. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/minor-color-diff-A.pdf +0 -0
  38. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/minor-color-diff-B.pdf +0 -0
  39. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/multiplatform-diff-A.pdf +0 -0
  40. {diffpdf-1.1.1 → diffpdf-1.2.0}/tests/assets/pass/multiplatform-diff-B.pdf +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diffpdf
3
- Version: 1.1.1
3
+ Version: 1.2.0
4
4
  Summary: A tool for comparing PDF files
5
5
  Project-URL: Homepage, https://github.com/JustusRijke/DiffPDF
6
6
  Project-URL: Issues, https://github.com/JustusRijke/DiffPDF/issues
@@ -16,7 +16,6 @@ Requires-Python: >=3.10.0
16
16
  Requires-Dist: click>=8
17
17
  Requires-Dist: pillow>=10.0.0
18
18
  Requires-Dist: pixelmatch-fast>=1.3.1
19
- Requires-Dist: pre-commit>=4.5.1
20
19
  Requires-Dist: pymupdf>=1.23.0
21
20
  Description-Content-Type: text/markdown
22
21
 
@@ -62,6 +61,7 @@ Options:
62
61
  --dpi INTEGER Render resolution
63
62
  --output-dir DIRECTORY Diff output directory (saves text diffs and visual diff images on failure)
64
63
  -v, --verbose Increase verbosity
64
+ --skip-compare-text Skip text content comparison
65
65
  --version Show the version and exit.
66
66
  --help Show this message and exit.
67
67
  ```
@@ -84,6 +84,14 @@ diffpdf("reference.pdf", "actual.pdf")
84
84
  diffpdf("reference.pdf", "actual.pdf", output_dir="./output", dpi=300)
85
85
  ```
86
86
 
87
+ ## Cross-Platform Considerations
88
+
89
+ PDF rendering may differ slightly between platforms due to different font
90
+ rendering engines (ClearType on Windows, FreeType on Linux). DiffPDF's
91
+ default threshold accounts for these minor differences.
92
+
93
+ **Tip:** Generate reference PDFs on the same platform as your CI environment
94
+
87
95
  ## Development
88
96
 
89
97
  Install [uv](https://github.com/astral-sh/uv?tab=readme-ov-file#installation). Then, install dependencies & activate the automatically generated virtual environment:
@@ -40,6 +40,7 @@ Options:
40
40
  --dpi INTEGER Render resolution
41
41
  --output-dir DIRECTORY Diff output directory (saves text diffs and visual diff images on failure)
42
42
  -v, --verbose Increase verbosity
43
+ --skip-compare-text Skip text content comparison
43
44
  --version Show the version and exit.
44
45
  --help Show this message and exit.
45
46
  ```
@@ -62,6 +63,14 @@ diffpdf("reference.pdf", "actual.pdf")
62
63
  diffpdf("reference.pdf", "actual.pdf", output_dir="./output", dpi=300)
63
64
  ```
64
65
 
66
+ ## Cross-Platform Considerations
67
+
68
+ PDF rendering may differ slightly between platforms due to different font
69
+ rendering engines (ClearType on Windows, FreeType on Linux). DiffPDF's
70
+ default threshold accounts for these minor differences.
71
+
72
+ **Tip:** Generate reference PDFs on the same platform as your CI environment
73
+
65
74
  ## Development
66
75
 
67
76
  Install [uv](https://github.com/astral-sh/uv?tab=readme-ov-file#installation). Then, install dependencies & activate the automatically generated virtual environment:
@@ -26,7 +26,6 @@ dependencies = [
26
26
  "pymupdf>=1.23.0",
27
27
  "pixelmatch-fast>=1.3.1",
28
28
  "Pillow>=10.0.0",
29
- "pre-commit>=4.5.1",
30
29
  ]
31
30
 
32
31
  [project.urls]
@@ -39,6 +38,8 @@ dev = [
39
38
  "pytest-cov>=6",
40
39
  "ruff>=0.10",
41
40
  "ty>=0.0.8",
41
+ "pre-commit>=4.5.1",
42
+ "nodeenv>=1.4.0", # Required for pre-commit
42
43
  ]
43
44
 
44
45
  [project.scripts]
@@ -17,6 +17,7 @@ def diffpdf(
17
17
  dpi: int = 96,
18
18
  output_dir: str | Path | None = None,
19
19
  verbose: bool = False,
20
+ skip_compare_text: bool = False,
20
21
  ) -> bool:
21
22
  ref_path = Path(reference) if isinstance(reference, str) else reference
22
23
  actual_path = Path(actual) if isinstance(actual, str) else actual
@@ -34,9 +35,12 @@ def diffpdf(
34
35
  if not check_page_counts(ref_path, actual_path):
35
36
  return False
36
37
 
37
- logger.info("[3/4] Checking text content...")
38
- if not check_text_content(ref_path, actual_path, out_path):
39
- return False
38
+ if skip_compare_text:
39
+ logger.info("[3/4] Skipping text content check")
40
+ else:
41
+ logger.info("[3/4] Checking text content...")
42
+ if not check_text_content(ref_path, actual_path, out_path):
43
+ return False
40
44
 
41
45
  logger.info("[4/4] Checking visual content...")
42
46
  if not check_visual_content(ref_path, actual_path, threshold, dpi, out_path):
@@ -28,6 +28,11 @@ from .logger import setup_logging
28
28
  is_flag=True,
29
29
  help="Increase verbosity",
30
30
  )
31
+ @click.option(
32
+ "--skip-compare-text",
33
+ is_flag=True,
34
+ help="Skip text content comparison (useful when different render engines produce identical-looking PDFs with different text extraction order)",
35
+ )
31
36
  @click.version_option(package_name="diffpdf")
32
37
  def cli(
33
38
  reference: Path,
@@ -36,10 +41,13 @@ def cli(
36
41
  dpi: int,
37
42
  output_dir: Path | None,
38
43
  verbose: bool,
44
+ skip_compare_text: bool,
39
45
  ) -> None:
40
46
  """Compare two PDF files for structural, textual, and visual differences."""
41
47
  try:
42
- if diffpdf(reference, actual, threshold, dpi, output_dir, verbose):
48
+ if diffpdf(
49
+ reference, actual, threshold, dpi, output_dir, verbose, skip_compare_text
50
+ ):
43
51
  sys.exit(0)
44
52
  else:
45
53
  sys.exit(1)
@@ -31,6 +31,24 @@ def test_api(ref_pdf_rel, actual_pdf_rel, should_pass):
31
31
  assert result == should_pass
32
32
 
33
33
 
34
+ def test_skip_compare_text():
35
+ ref_pdf = TEST_ASSETS_DIR / "fail/1-letter-diff-A.pdf"
36
+ actual_pdf = TEST_ASSETS_DIR / "fail/1-letter-diff-B.pdf"
37
+
38
+ # Without skip: fails at text stage
39
+ assert diffpdf(ref_pdf, actual_pdf) is False
40
+ # With skip: text stage bypassed, fails at visual stage (letter difference is visible)
41
+ assert diffpdf(ref_pdf, actual_pdf, skip_compare_text=True) is False
42
+
43
+
44
+ def test_skip_compare_text_multiplatform():
45
+ ref_pdf = TEST_ASSETS_DIR / "pass/multiplatform-diff-A.pdf"
46
+ actual_pdf = TEST_ASSETS_DIR / "pass/multiplatform-diff-B.pdf"
47
+
48
+ # Multiplatform PDFs already pass with text comparison
49
+ assert diffpdf(ref_pdf, actual_pdf, skip_compare_text=True) is True
50
+
51
+
34
52
  def test_text_diff_output(tmp_path):
35
53
  ref_pdf = TEST_ASSETS_DIR / "fail/1-letter-diff-A.pdf"
36
54
  actual_pdf = TEST_ASSETS_DIR / "fail/1-letter-diff-B.pdf"
@@ -20,6 +20,19 @@ def test_cli_with_output_dir():
20
20
  assert Path("./diff").exists()
21
21
 
22
22
 
23
+ def test_skip_compare_text_flag():
24
+ runner = CliRunner()
25
+ result = runner.invoke(
26
+ cli,
27
+ [
28
+ str(TEST_ASSETS_DIR / "pass/multiplatform-diff-A.pdf"),
29
+ str(TEST_ASSETS_DIR / "pass/multiplatform-diff-B.pdf"),
30
+ "--skip-compare-text",
31
+ ],
32
+ )
33
+ assert result.exit_code == 0
34
+
35
+
23
36
  def test_verbose_flag():
24
37
  runner = CliRunner()
25
38
  result = runner.invoke(