Sfoglia il codice sorgente

Update mineru/utils/draw_bbox.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Xiaomeng Zhao 3 mesi fa
parent
commit
0eec0d90b5
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      mineru/utils/draw_bbox.py

+ 5 - 1
mineru/utils/draw_bbox.py

@@ -25,7 +25,11 @@ def cal_canvas_rect(page, bbox):
     actual_height = page_height  # The height of the final PDF display
     
     rotation_obj = page.get("/Rotate", 0)
-    rotation = int(rotation_obj) % 360  # cast rotation to int to handle IndirectObject
+    try:
+        rotation = int(rotation_obj) % 360  # cast rotation to int to handle IndirectObject
+    except (ValueError, TypeError) as e:
+        logger.warning(f"Invalid /Rotate value {rotation_obj!r} on page; defaulting to 0. Error: {e}")
+        rotation = 0
     
     if rotation in [90, 270]:
         # PDF is rotated 90 degrees or 270 degrees, and the width and height need to be swapped