Creating Kindle books from PDF’s

OK, for some reason this problem has occupied the part of my mind that was supposed to be working on creating a masterful work of fiction. So, if I document the process here, maybe I can unchain that part of my psyche that has been trapped and move on.

Hey, I can hope.

OK, so, you have some PDF’s that your really interested in having on your kindle, but its either cost prohibitive or you have too many to be spending your time emailing them all. Here’s what you do (this assumes your A) on linux and B) have a working knowledge of, like, something). The resulting kindle books will not be pretty, I haven’t played with images yet, and no, there is no table of contents. But, most importantly, at least to me, the text is readable no matter what the font level, and there aren’t any weird breaks or anything.

Pre-reqs:

  1. You’ll need a copy of the popler utilities, in particular pdftotext
  2. Install wine. Sorry. Yeah, really, install it.
  3. You’ll need to grab mobigen and use wine to install/run it. Sorry, only way I have found. Don’t worry, it installs cleanly in wine, just be sure to locate and grab a copy of the msvcp71.dll. This is a command line windows utility for creating mobibooks, which the Kindle can read and translate.

OK, now that you have all of that, first:

pdftotext -layout -nopgbrk YOUR.pdf OUTPUT.txt

Which will translate your PDF into a text file. I played with pdftohtml (since mobigen needs an HTML file to read), but the output was always lacking. I found it easier to make a text file and add the trace amounts of html needed for this to work then to try and break down the crappy html pdftohtml produced. OK, text file generated, we now:

echo “<html><head><title>BOOK TITLE</title><meta name=”Subject” content=”BOOK TITLE”><meta name=”Author” content=”AUTHOR”></head><body>” >OUTPUT.HTML && cat OUTPUT.txt | perl -pe “s{^n}{n<p>n}g”|perl -pe “s{n}{ }g”>> OUTPUT.html && echo “</body></html>”>>OUTPUT.html

Yeah, that’s really all one line – that’s just how I roll. Finally,

wine /usr/local/mobigen/mobigen.exe OUTPUT.html  -c1 -s0

with, of course, that being the path to where you unpacked mobigen (I put it in /usr/local/mogbigen myself). The result is a mobi file that you can plop on your kindle and read at ease.

Enjoy!

  1. Kindle Touch 3g…

    […]Creating Kindle books from PDF’s « datanode.net[…]…

  2. Fictional Books Blog and Review…

    […]Creating Kindle books from PDF’s « datanode.net[…]…

Comments are closed.