Is there a way to convert a PDF document into an eBook format such as epub, azw or mobi? I am looking for an application, which is fast in conversion. I have just tried calibre. After 10 minutes not even 2% of the conversion have been reached. So please no calibre. CLI is preferred.


You should try pdftotext (comes under Ubuntu in the package poppler-utils). It is a commandline converter. It assumes that the PDF has text and does not consist of images only.

If the PDF file consists of images (without OCR info), you have to go for an OCR solution, which is much slower.

I have successfully used the OCR method as well on PDF text which was scrambled (by positioning the individual characters on a page in a non-linear fashion). Then you use e.g. pdftoppm to get individual images of the pages and OCR those.


I generally use Calibre, to convert from the various formats (epub, mobi, and pdf). It's pretty straightforward to convert with it, here's a screenshot, there are others and a video tutorial as well.


   ss of calibre

  • 3
    What part of "please no calibre" is unclear? – mlp Apr 28 '13 at 6:26
  • 5
    When answer questions on any SE site you're servicing both the OP and anyone that finds this Q&A thread in the future. This answer is meant to cover all the bases for those individuals. Also Calibre might be the best option, perhaps the OP had a buggy version OR it was misconfigured. I've used it dozens of times and it does a fine job of converting. – slm Apr 28 '13 at 11:02
  • I am not able to convert the pfd file to epub in a fixed layout. Could you please tell me what are the steps need to follow to convert a pdf to epub in a fixed layout. – mohan rathour May 28 at 7:50

I had to do this for a PDF file once, and this was the result (using pdftohtml from poppler):


tmpdir="`mktemp -d`"

pdftohtml -enc UTF-8 -noframes -p -nomerge -nodrm -q "$1" "$tmpdir"/index

cd "$tmpdir"

sed -e :a -e '$!N;s/\n/ /;ta' \
    -i index.html 

sed -e 's@ @ @g' \
    -e 's@<hr>@ @g' \
    -e 's@<br/>\s*<br/>@</p><p>@g' \
    -e 's@<br/>@ @g' \
    -i index.html

tidy -utf8 -i -wrap 9999999 -m index.html

sed -e 's@<a name="[^"]*"></a>@@g' \
    -i index.html

rm "$pwddir"/"$1".zip
zip "$pwddir"/"$1".zip *

Feed the zip to Calibre and convert to EPUB. Filter all CSS properties (such as colors, fonts).

Every PDF file is different - there is no definitive solution. The above worked for one specific case - you have to weak pdftohtml/pdftotext and then tweak the output to fit your needs.

If this fails and you have to resort to OCR, I've had some luck with cuneiform. But also try tesseract, ocrad, gocr. However all of those require manual labor for a good result.

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.