소스 검색

Update mineru/utils/draw_bbox.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Xiaomeng Zhao 3 달 전
부모
커밋
0eec0d90b5
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  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