Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I used tesseract to produce the special html to use with hocr2pdf starting from a muti-page tif.

I tried using hoc2pdf to produce a "sandwich pdf" (image + hidden text layer).

Hocr2pdf produces a one page pdf with all the pages superimposed.

Is there a way to solve this problem or an alternative solution?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I found a workaround to this issue. Hocr2pdf has issues with producing multi-page pdfs so I produced single-page tifs, ran tesseract-ocr, ran hocr2pdf then combined the results with the following script:

for f in ./*.tif; do
   tesseract "$f" "$f" -l fra hocr
   hocr2pdf -i "$f" -s -o "$f.pdf" < "$f.html"
pdftk *.tif.pdf cat output "output.pdf" && rm *.tif.pdf && rm *.tif.html
share|improve this answer
Thanks, this seems to be the closest way, in Ubuntu, to convert an image-based pdf into one that has some text capabilities. Unfortunately the small set of default fonts and relatively rough positioning makes the output text line up rather poorly with the image. I wish there was a more complete solution; this is almost it! – waldyrious Jun 11 '13 at 19:11
I'm actually using PDF X-Change viewer through Wine. The result is much better. – To Do Jun 18 '13 at 15:01
Just tried the trial version. Indeed it places the text pretty much exactly, apparently by placing each word individually rather than blocks of text. The only thing missing is the ability to tweak the OCR for the inevitable errors... is there any way to open the already OCR'd pdfs in OCRfeeder? I found its interface quite easy to use but I can't seem to get it to detect the existing text layer... I also tried PDFedit but its interface is way too advanced for mortals like me! – waldyrious Jun 19 '13 at 5:11
@ToDo: I like your reply. I actually have a pdf file and a html file in hocr format. Can I merge the hocr file into the pdf file, to make the pdf file searchable, without converting the pdf file to single-page image files? See… – Tim Nov 27 '14 at 13:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.