Spaces:
Sleeping
Sleeping
Version 10
Browse files- paddle_ocr_standalone.py +4 -3
paddle_ocr_standalone.py
CHANGED
|
@@ -113,9 +113,10 @@ try:
|
|
| 113 |
doc = fitz.open(pdf_path)
|
| 114 |
image_paths = []
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
-
for page_num in range(
|
| 119 |
try:
|
| 120 |
safe_print_stderr(f"Converting page {page_num + 1}...")
|
| 121 |
page = doc[page_num]
|
|
@@ -146,7 +147,7 @@ try:
|
|
| 146 |
continue
|
| 147 |
|
| 148 |
doc.close()
|
| 149 |
-
safe_print_stderr(f"✓ Successfully converted {len(image_paths)}/{
|
| 150 |
return image_paths
|
| 151 |
|
| 152 |
except Exception as e:
|
|
|
|
| 113 |
doc = fitz.open(pdf_path)
|
| 114 |
image_paths = []
|
| 115 |
|
| 116 |
+
total_pages = len(doc) # Store this before we close the document
|
| 117 |
+
safe_print_stderr(f"PDF has {total_pages} pages")
|
| 118 |
|
| 119 |
+
for page_num in range(total_pages):
|
| 120 |
try:
|
| 121 |
safe_print_stderr(f"Converting page {page_num + 1}...")
|
| 122 |
page = doc[page_num]
|
|
|
|
| 147 |
continue
|
| 148 |
|
| 149 |
doc.close()
|
| 150 |
+
safe_print_stderr(f"✓ Successfully converted {len(image_paths)}/{total_pages} pages")
|
| 151 |
return image_paths
|
| 152 |
|
| 153 |
except Exception as e:
|