pdfinspector / repro_error.py
rianders's picture
Include example PDFs with Git LFS and add helper scripts
e6ea8c6
Raw History Blame Contribute Delete
1.07 kB
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()