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

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?

share|improve this question

2 Answers 2

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

share|improve this answer
+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… – 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.

share|improve this answer

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.