Spaces:
Sleeping
Sleeping
Monkey Patch attempt #2
Browse files
app.py
CHANGED
|
@@ -63,9 +63,24 @@ def monkey_patch_pymupdf():
|
|
| 63 |
|
| 64 |
fitz.Document.pageCount = property(pageCount_property)
|
| 65 |
print("Added pageCount compatibility property to PyMuPDF Document class")
|
| 66 |
-
|
| 67 |
-
#
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
# Try alternative PaddlePaddle versions
|
| 71 |
def try_paddle_import():
|
|
|
|
| 63 |
|
| 64 |
fitz.Document.pageCount = property(pageCount_property)
|
| 65 |
print("Added pageCount compatibility property to PyMuPDF Document class")
|
| 66 |
+
|
| 67 |
+
# Add getPixmap method to Page class if it doesn't exist
|
| 68 |
+
if not hasattr(fitz.Page, 'getPixmap'):
|
| 69 |
+
def getPixmap(self, matrix=None, alpha=True):
|
| 70 |
+
return self.get_pixmap(matrix=matrix, alpha=alpha)
|
| 71 |
+
|
| 72 |
+
fitz.Page.getPixmap = getPixmap
|
| 73 |
+
print("Added getPixmap compatibility method to PyMuPDF Page class")
|
| 74 |
+
|
| 75 |
+
# Add other common compatibility methods if needed
|
| 76 |
+
if not hasattr(fitz.Page, 'getText'):
|
| 77 |
+
def getText(self, option="text"):
|
| 78 |
+
return self.get_text(option)
|
| 79 |
+
|
| 80 |
+
fitz.Page.getText = getText
|
| 81 |
+
print("Added getText compatibility method to PyMuPDF Page class")
|
| 82 |
+
|
| 83 |
+
print("PyMuPDF compatibility patches applied successfully")
|
| 84 |
|
| 85 |
# Try alternative PaddlePaddle versions
|
| 86 |
def try_paddle_import():
|