Skip to content

Commit 52c858d

Browse files
authored
Update for newer versions of PuMuPDF
1 parent 6ef9de0 commit 52c858d

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,19 @@ Python>=3.7
4040

4141
```text
4242
PyQt6>=6.7.0
43-
PyMuPDF>=1.24.3
43+
PyMuPDF>=1.26.5
4444
```
4545

4646
## Install & Run
4747

4848
### install from source
4949

50-
you will need `setuptools` and `wheel` installed
50+
you will need git, `setuptools` and `wheel` installed
5151

5252
```bash
53-
$ cd <path>
54-
$ pip install .
53+
$ pip install git+https://github.com/Augus1999/pyPDFeditor-GUI.git
5554
```
5655

57-
where `<path>` is the directory `setup.py` locates.
58-
5956
### build thy own package
6057

6158
this requires `build`, `setuptools` and `wheel` installed

pypdfeditor_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
__system__ = platform.system()
1717
__author__ = "Nianze A. TAO (Omozawa SUENO)"
18-
__version__ = "3.0.10"
18+
__version__ = "3.0.11"
1919
__all__ = ["main", "reset", "remove"]
2020

2121

pypdfeditor_core/functions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
from typing import Union, Optional, Tuple, List, Dict
1212
from pathlib import Path
1313
from pymupdf.mupdf import FzErrorFormat, FzErrorLibrary
14-
from pymupdf import Document, Page, Pixmap, Rect, Point, Font
15-
from pymupdf.utils import get_pixmap, set_metadata, Shape
14+
from pymupdf import Document, Page, Pixmap, Rect, Point, Font, Shape
1615
from pymupdf import TOOLS, Matrix, Identity
1716
from PyQt6 import QtGui, QtCore, QtWidgets
1817
from PyQt6.QtWidgets import (
@@ -116,7 +115,7 @@ def render_pdf_page(page_data: Page) -> QtGui.QPixmap:
116115
:param page_data: page data
117116
:return: a QPixmap
118117
"""
119-
page_pixmap = get_pixmap(page_data, matrix=Identity, clip=True)
118+
page_pixmap = page_data.get_pixmap(matrix=Identity, clip=True)
120119
if page_pixmap.alpha:
121120
image_format = QtGui.QImage.Format.Format_RGBA8888
122121
else:
@@ -485,7 +484,9 @@ def save_as(index: int, widget: QWidget, main: QWidget) -> None:
485484
:return: None
486485
"""
487486
doc = Document()
488-
doc.insert_pdf(widget.book, widget.book_list[index], widget.book_list[index])
487+
doc.insert_pdf(
488+
widget.book, from_page=widget.book_list[index], to_page=widget.book_list[index]
489+
)
489490
f_name = (
490491
os.path.splitext(os.path.basename(widget.book.name))[0]
491492
+ f"-{widget.book_list[index] + 1}.pdf"
@@ -500,8 +501,7 @@ def save_as(index: int, widget: QWidget, main: QWidget) -> None:
500501
if file_name.endswith(".pdf"):
501502
doc.save(file_name)
502503
if file_name.endswith((".psd", ".png", ".ppm")):
503-
pix = get_pixmap(
504-
doc[0],
504+
pix = doc[0].get_pixmap(
505505
dpi=220,
506506
alpha=False if file_name.endswith(".ppm") else True,
507507
)
@@ -697,7 +697,7 @@ def set_metadata0(doc: Doc, author: Optional[str]) -> None:
697697
)
698698
metadata["author"] = author
699699
doc.xref_set_key(-1, "Info", "null") # remove all original xref
700-
set_metadata(doc, remove_invalid_xref_key(metadata))
700+
doc.set_metadata(remove_invalid_xref_key(metadata))
701701

702702

703703
def set_metadata1(

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
PyMuPDF>=1.24.3
1+
PyMuPDF>=1.26.5
22
PyQt6>=6.7.0

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@
4141
package_dir={"pypdfeditor_core": "pypdfeditor_core"},
4242
license="MIT",
4343
python_requires=">=3.7",
44-
install_requires=["PyMuPDF>=1.24.3", "PyQt6>=6.7.0"],
44+
install_requires=["PyMuPDF>=1.26.5", "PyQt6>=6.7.0"],
4545
url="https://github.com/Augus1999/pyPDFeditor-GUI/",
4646
project_urls={"Source": "https://github.com/Augus1999/pyPDFeditor-GUI"},
4747
include_package_data=True,
4848
package_data={"pypdfeditor_core": ["icons/*.svg", "icons/*.py"]},
4949
classifiers=[
5050
"Development Status :: 5 - Production/Stable",
5151
"Intended Audience :: End Users/Desktop",
52-
"License :: OSI Approved :: MIT License",
5352
"Natural Language :: Chinese (Traditional)",
5453
"Natural Language :: English",
5554
"Natural Language :: Japanese",
@@ -62,6 +61,7 @@
6261
"Programming Language :: Python :: 3.10",
6362
"Programming Language :: Python :: 3.11",
6463
"Programming Language :: Python :: 3.12",
64+
"Programming Language :: Python :: 3.13",
6565
"Topic :: Office/Business",
6666
],
6767
entry_points={"console_scripts": ["pdfeditor=pypdfeditor_core:main"]},

0 commit comments

Comments
 (0)