Skip to content

Commit 0362d28

Browse files
authored
Merge pull request #232 from openstate/main
Fix for ZeroDivisionError for cwidth in pymupdf_rag.py
2 parents 49d915b + 85d0f57 commit 0362d28

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pymupdf4llm/pymupdf4llm/helpers/pymupdf_rag.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ def write_text(
592592
cwidth = (span0["bbox"][2] - span0["bbox"][0]) / len(
593593
span0["text"]
594594
)
595+
if cwidth == 0.0:
596+
cwidth = span0["size"] * 0.5
595597
text = " " * int(round(dist / cwidth)) + text
596598
out_string += text
597599
if not code:

0 commit comments

Comments
 (0)