Following the instructions from this page

I take a djvu document, check it for any sign of corruption by opening it in djvulibre and it checks out fine. Copy it to my testing folder and rename it


djvu2hocr test.djvu | sed 's/ocrx/ocr/g' > test.html

ddjvu -format=tiff test.djvu test.tif

Proceed to open the tif with evince and it checks out all pages are viewable.

Run pdfbeads

pdfbeads -o test.pdf

and get the following error:

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead. Prepared data for processing test.tif Warning: test.tif contains multiple images, but only the first one is going to be used JBIG2 compression complete. pages:1 symbols:2080 log2:12 Processed test.tif

The PDF opens fine, but it is only a single page and the OCR works.

Here's a link to the files copied/generated

Any suggestions?


pdfbeads expects a single page TIFF file and a single page html hOCR file for every page in the document. If it can only find one TIFF file, it will only output one page.

Split the TIFF file with tiffsplit. hocrsplit from hocr-tools might be able to split your html. Never needed to use it, myself.

I wouldn't worry about the iconv warning. Ruby always does that with pdfbeads. Reason here: iconv deprecation warning with ruby 1.9.3 - Stack Overflow

  • +1. I like your reply. If I 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 unix.stackexchange.com/questions/170133/… – Tim Nov 27 '14 at 14:10
  • I don't know; have never needed to do that. One useful thing that has changed since my answer: tesseract can now go directly from TIFF → PDF with OCR information. It's not as compact as pdfbeads, but it's lossless. – scruss Nov 28 '14 at 1:41

I can no longer remember if I wrote the following modification to the instructions you posted above, or if I found them somewhere else (though a Google search gives no relevant results), the following is what I've been using for many months now to convert whole djvu files into pdf format.

pg=$(djvused -e 'n' $f)
for i in $(seq 1 $pg)
    djvu2hocr -p $i $f | sed 's/ocrx/ocr/g' > `printf "pg%04d.html" $i`
    ddjvu -format=tiff -page=$i $f `printf "pg%04d.tiff" $i`
pdfbeads -o ${f/djvu/pdf};

This creates a separate tiff (and corresponding html file) for every page, and then merges everything together using pdfbeads. Note that if for some reason your djvu has over 9999 pages you will need to change the instances of %04 to something larger, like %05.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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