gcv2hocr converts from Google Cloud Vision OCR output to hocr to make a searchable pdf.
- How to make a searchable pdf:
make install PREFIX=$HOME/.local
gcv2hocr test.jpg.json output.hocr
test.jpg.json is a output of Google Cloud Vision OCR.
output.hocr is a output of gcv2hocr.
You may specify image size in argument.
gcv2hocr test.jpg.json output.hocr 1280 960
1280 is image height of the picture.
960 is image width of the picture.
gcv2hocr also generates intermediary files
You may use gcv2hocr.py instead of gcv2hocr executable.
python gcv2hocr.py test.jpg.json > output.hocr
--savefile (python only) if defined will output to file instead of console.
How to get OCR (json) data:
./gcvocr.sh test.jpg "Your API KEY"
gcvocr.sh is slightly modified sample.sh originally written by Kazuhiro FURUHATA (firstname.lastname@example.org).
How to make a searchable pdf:
To create a searchable pdf, use the
hocr-pdf script bundled with
makepdf.sh is a sample shell script to make a searchable pdf from individual jpeg files.
To Kazuhiro FURUHATA, he gave me a permission redistribute and modify sample.sh.
To Philipp Zumstein, he gave me answers several questions about hocr.
To Konstantin Baierer, he wrote python port (gcv2hocr.py).
To skylord123, he fixed many bugs in python port.
To URIN HACK, he gave me a permission redistribute his replace() code. (http://urin.github.io/posts/2018/replace-string-by-c-lang)
Creative Commons Attribution 4.0 International. You are free to: Share — copy and redistribute the material in any medium or format Adapt — remix, transform, and build upon the material for any purpose, even commercially. The licensor cannot revoke these freedoms as long as you follow the license terms.
2016.9.2 ENDO Michiaki (email@example.com)