From 4eacb3454f142dc8b3f590d592140a0ed5e506f7 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 29 Sep 2020 02:45:11 -0700 Subject: [PATCH] hOCR: write text in correct order Fixes #642 --- src/ocrmypdf/hocrtransform.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/hocrtransform.py b/src/ocrmypdf/hocrtransform.py index 7e2ef142..6631cf1e 100755 --- a/src/ocrmypdf/hocrtransform.py +++ b/src/ocrmypdf/hocrtransform.py @@ -167,7 +167,10 @@ class HocrTransform: def topdown_position(self, element): pxl_line_coords = self.element_coordinates(element) line_box = self.pt_from_pixel(pxl_line_coords) - return -line_box.y2 + # Coordinates here are still in the hocr coordinate system, so 0 on the y axis + # is the top of the page and increasing values of y will move towards the + # bottom of the page. + return line_box.y2 def to_pdf( self,