diff --git a/hocr-pdf b/hocr-pdf index 58405ab..3b9cdc4 100755 --- a/hocr-pdf +++ b/hocr-pdf @@ -31,6 +31,7 @@ import imghdr from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfgen.canvas import Canvas +from bidi.algorithm import get_display from lxml import etree, html from PIL import Image @@ -141,6 +142,7 @@ def add_text_layer(pdf, image, height, dpi): text.setTextOrigin(box[0] * 72 / dpi, height - b * 72 / dpi) box_width = (box[2] - box[0]) * 72 / dpi text.setHorizScale(100.0 * box_width / font_width) + rawtext = get_display(rawtext) text.textLine(rawtext) pdf.drawText(text)