Spaces:
Sleeping
Sleeping
File size: 1,072 Bytes
e6ea8c6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import pymupdf as fitz
from layout_utils import extract_blocks_spans
def test_extraction():
# Open the real PDF
doc = fitz.open("logic.pdf")
# doc.new_page() ... no
# Analyze it using the function I modified
try:
blocks = extract_blocks_spans(doc, 0)
print(f"Blocks extracted: {len(blocks)}")
for i, b in enumerate(blocks):
bbox = b.bbox
print(f"Block {i} bbox type: {type(bbox)}")
if isinstance(bbox, tuple):
print(f"Block {i} bbox len: {len(bbox)}")
if len(bbox) == 4:
print(f"Block {i} sample: {bbox}")
# Try unpacking
x0, y0, x1, y1 = bbox
# Try explicit float cast
_ = float(x0)
else:
print(f"Block {i} bbox is NOT tuple: {bbox}")
except Exception as e:
print(f"Error caught: {type(e).__name__}: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_extraction()
|