Fixed the way right to left language (Hebrew) text is inserted to pdf #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Description:
The pdf file generated using
hocr-pdf
has Hebrew text printed in the opposite direction.Steps I followed:
hocr-pdf --savefile output.pdf actual-file.jpg
to generate pdf file.The pdf file has Hebrew text inserted in it but in the reverse order.
Actual image:
This is how hocr file looks:
Text in pdf file: (I have set text visibility mode to 0 so that the inserted text is visible)
Solution:
Use python package for bidi algorithm ( Bi-Directional Algorithm ) to transform text before drawing it into the pdf file.
Solution is based on the suggestion: ocropus#163
Tests:
Tested both Hebrew text image and English text image and they give expected results.
For Issue:
https://github.com/StarfishCo/api.raven.com/issues/3740