Skip to content

Commit

Permalink
check PyMuPDF version: 1.19.0<=v<=1.23.8 or v>=1.23.16
Browse files Browse the repository at this point in the history
  • Loading branch information
dothinking committed Jan 19, 2024
1 parent 45587dd commit cbcbefe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 6 additions & 8 deletions pdf2docx/common/Element.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'''Object with a bounding box, e.g. Block, Line, Span.
Based on ``PyMuPDF``, the coordinates (e.g. bbox of ``page.get_text('rawdict')``) are generally
provided relative to the un-rotated page; while this ``pdf2docx`` library works under real page
coordinate system, i.e. with rotation considered. So, any instances created by this Class are
Based on ``PyMuPDF``, the coordinates (e.g. bbox of ``page.get_text('rawdict')``) are generally
provided relative to the un-rotated page; while this ``pdf2docx`` library works under real page
coordinate system, i.e. with rotation considered. So, any instances created by this Class are
always applied a rotation matrix automatically.
Therefore, the bbox parameter used to create ``Element`` instance MUST be relative to un-rotated
Expand Down Expand Up @@ -34,7 +34,7 @@ def set_rotation_matrix(cls, rotation_matrix):
Args:
Rotation_matrix (fitz.Matrix): target matrix
"""
"""
if rotation_matrix and isinstance(rotation_matrix, fitz.Matrix):
cls.ROTATION_MATRIX = rotation_matrix

Expand Down Expand Up @@ -198,8 +198,7 @@ def vertically_align_with(self, e, factor:float=0.0, text_direction:bool=True):
e (Element): Object to check with
factor (float, optional): Threshold of overlap ratio, the larger it is, the higher
probability the two bbox-es are aligned.
text_direction (bool, optional): Consider text direction or not.
True by default,from left to right if False.
text_direction (bool, optional): Consider text direction or not. True by default.
Returns:
bool: [description]
Expand Down Expand Up @@ -240,8 +239,7 @@ def horizontally_align_with(self, e, factor:float=0.0, text_direction:bool=True)
e (Element): Element to check with
factor (float, optional): threshold of overlap ratio, the larger it is, the higher
probability the two bbox-es are aligned.
text_direction (bool, optional): consider text direction or not.
True by default, from left to right if False.
text_direction (bool, optional): consider text direction or not. True by default.
Examples::
Expand Down
8 changes: 5 additions & 3 deletions pdf2docx/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
from .page.Page import Page
from .page.Pages import Pages

# check PyMuPDF>=1.19.x
if list(map(int, fitz.VersionBind.split("."))) < [1, 19, 0]:
raise SystemExit("PyMuPDF>=1.19.0 is required for pdf2docx.")
# check PyMuPDF version
# 1.19.0 <= v <= 1.23.8, or v>=1.23.16
v = list(map(int, fitz.VersionBind.split(".")))
if v < [1,19,0] or [1,23,8]<v<[1,23,16]:
raise SystemExit("1.19.0 <= PyMuPDF <= 1.23.8, or PyMuPDF>=1.23.16 is required for pdf2docx.")

# logging
logging.basicConfig(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PyMuPDF==1.23.8
PyMuPDF
python-docx>=0.8.10
fonttools>=4.24.0
numpy>=1.17.2
Expand Down

0 comments on commit cbcbefe

Please sign in to comment.