From 6bbde085d84ac66fb06ac62fc75e5163192ed435 Mon Sep 17 00:00:00 2001 From: SUENO Omozawa <39725660+Augus1999@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:27:32 +0900 Subject: [PATCH] Version 3.0.2 * Fixed a bug while handling wrong format. --- pypdfeditor_core/__init__.py | 2 +- pypdfeditor_core/functions.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pypdfeditor_core/__init__.py b/pypdfeditor_core/__init__.py index ffd33b0..fa8b647 100644 --- a/pypdfeditor_core/__init__.py +++ b/pypdfeditor_core/__init__.py @@ -15,7 +15,7 @@ __system__ = platform.system() __author__ = "Nianze A. TAO (Omozawa SUENO)" -__version__ = "3.0.1" +__version__ = "3.0.2" __all__ = ["main", "reset", "remove"] diff --git a/pypdfeditor_core/functions.py b/pypdfeditor_core/functions.py index 5f775ac..be1bafb 100644 --- a/pypdfeditor_core/functions.py +++ b/pypdfeditor_core/functions.py @@ -10,6 +10,7 @@ import time from typing import Union, Optional, Tuple, List from pathlib import Path +from pymupdf.mupdf import FzErrorFormat from pymupdf import Document, Page, Pixmap, Rect, Point, Font from pymupdf.utils import get_pixmap, set_metadata, Shape from pymupdf import TOOLS, Matrix, Identity @@ -77,7 +78,7 @@ def open_pdf(file_name: str, parent: QWidget) -> Tuple[Optional[Doc], bool]: try: # handle wrong image formats pdf_bites = Pixmap(file_name).tobytes() doc = Doc("png", pdf_bites) - except RuntimeError: + except FzErrorFormat: return _open_warning(parent) pdf_bites = doc.convert_to_pdf() # convert to pdf doc = Doc("pdf", pdf_bites)