hocr: avoid division by zero
Issue #253 - PDF that produces the error is not available, but if font_width is zero, chances are the text is nonprinting characters, so suppress it.
This commit is contained in:
@@ -322,8 +322,11 @@ class HocrTransform():
|
||||
dy = baseline_y2 - cursor[1]
|
||||
text.moveCursor(dx, dy)
|
||||
|
||||
text.setHorizScale(100 * box_width / font_width)
|
||||
text.textOut(elemtxt)
|
||||
# If reportlab tells us this word is 0 units wide, our best seems
|
||||
# to be to suppress this text
|
||||
if font_width > 0:
|
||||
text.setHorizScale(100 * box_width / font_width)
|
||||
text.textOut(elemtxt)
|
||||
pdf.drawText(text)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user