Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ body:
attributes:
label: PyMuPDF version
options:
- 1.27.1
- 1.27.0
- 1.26.7
- 1.26.6
Expand Down
12 changes: 10 additions & 2 deletions changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@ Change Log
==========


**Changes in version 1.27.0** ()
**Changes in version 1.27.1** ()

* Use MuPDF-1.27.0.
* Use MuPDF-1.27.1.

* Fixed issues:

* **Fixed** `2883 <https://github.com/pymupdf/PyMuPDF/issues/2883>`_: Improve the Python type annotations for fitz_new
* **Fixed** `4599 <https://github.com/pymupdf/PyMuPDF/issues/4599>`_: page.cluster_drawings extract a lot of small clusters once upgraded to 1.26
* **Fixed** `4751 <https://github.com/pymupdf/PyMuPDF/issues/4751>`_: Memory leaking in page.widgets()
* **Fixed** `4762 <https://github.com/pymupdf/PyMuPDF/issues/4762>`_: Importing pymupdf make pillow segmentation fault for converting jp2 file on ArchLinux

* Other:

* Added `pymupdf.TEXT_CLIP`.
* Removed support for mupdf < 1.26.
* Partial fix of `4790 <https://github.com/pymupdf/PyMuPDF/issues/4790>`_: Problem to delete pages on PDF

* New arg `raise_on_repair` in `Document.save()`.
* New method `Document.repair()`.

* Added py.typed file for type checkers.


**Changes in version 1.26.7** (2025-12-11)
Expand Down
46 changes: 28 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,25 +797,35 @@ def build_mupdf_windows(
):

assert mupdf_local

if overwrite_config:
mupdf_config_h = f'{mupdf_local}/include/mupdf/fitz/config.h'
prefix = '#define TOFU_CJK_EXT 1 /* PyMuPDF override. */\n'
with open(mupdf_config_h) as f:
text = f.read()
if text.startswith(prefix):
print(f'Not modifying {mupdf_config_h} because already has prefix {prefix!r}.')
else:
print(f'Prefixing {mupdf_config_h} with {prefix!r}.')
text = prefix + text
st = os.stat(mupdf_config_h)
with open(mupdf_config_h, 'w') as f:
f.write(text)
os.utime(mupdf_config_h, (st.st_atime, st.st_mtime))

mupdf_version_tuple = get_mupdf_version(mupdf_local)
log(f'{overwrite_config=}')
log(f'{mupdf_version_tuple=}')
wp = pipcl.wdev.WindowsPython()
tesseract = '' if os.environ.get('PYMUPDF_SETUP_MUPDF_TESSERACT') == '0' else 'tesseract-'
windows_build_tail = f'build\\shared-{tesseract}{build_type}'

if overwrite_config:
if mupdf_version_tuple >= (1, 28):
# Tell mupdf build to use, for example, `/Build "ReleaseTofuCjkExt|x64"`.
# This avoids the need for us to modify mupdf's config.h.
windows_build_tail += '-TOFU_CJK_EXT'
log(f'Appending, {windows_build_tail=}')
else:
log(f'modifying mupdf:include/mupdf/fitz/config.h')
mupdf_config_h = f'{mupdf_local}/include/mupdf/fitz/config.h'
prefix = '#define TOFU_CJK_EXT 1 /* PyMuPDF override. */\n'
with open(mupdf_config_h) as f:
text = f.read()
if text.startswith(prefix):
log(f'Not modifying {mupdf_config_h} because already has prefix {prefix!r}.')
else:
log(f'Prefixing {mupdf_config_h} with {prefix!r}.')
text = prefix + text
st = os.stat(mupdf_config_h)
with open(mupdf_config_h, 'w') as f:
f.write(text)
os.utime(mupdf_config_h, (st.st_atime, st.st_mtime))

if g_py_limited_api:
windows_build_tail += f'-Py_LIMITED_API_{pipcl.current_py_limited_api()}'
windows_build_tail += f'-x{wp.cpu.bits}-py{wp.version}'
Expand Down Expand Up @@ -1273,9 +1283,9 @@ def sdist():
#

# PyMuPDF version.
version_p = '1.27.0'
version_p = '1.27.1'

version_mupdf = '1.27.0'
version_mupdf = '1.27.1'

# PyMuPDFb version. This is the PyMuPDF version whose PyMuPDFb wheels we will
# (re)use if generating separate PyMuPDFb wheels. Though as of PyMuPDF-1.24.11
Expand Down
2 changes: 2 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7865,6 +7865,7 @@ def write(
preserve_metadata=1,
use_objstms=0,
compression_effort=0,
raise_on_repair=False,
):
from io import BytesIO
bio = BytesIO()
Expand All @@ -7889,6 +7890,7 @@ def write(
preserve_metadata=preserve_metadata,
use_objstms=use_objstms,
compression_effort=compression_effort,
raise_on_repair=raise_on_repair,
)
return bio.getvalue()

Expand Down
Binary file added tests/resources/test_4599.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/test_cluster_drawings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ def test_cluster3():
page.draw_rect(r1)
page.draw_rect(r2)
assert page.cluster_drawings() == [r1, r2]


def test_4599():
print()
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4599.pdf')
n = 0
with pymupdf.open(path) as document:
for page in document:
for clip in page.cluster_drawings():
print(clip)
n += 1
assert n == 3