Tag Archives: epub

epub.sh: Me and Anders and Esko

Some months ago Anders left a note here about a simple script to spill a .epub file into your terminal, without needing another application to read it. Anders credited Esko for the original version, and while it might be presumptuous, I have adjusted Anders’ version slightly too.

Here’s my contribution to the effort, which still needs a little attention at times.

if [[ -z "$1" ]]
    then echo "Usage: ./epub.sh book.epub"
if [[ -z "$2" ]]
    then COLS=`tput cols`
FILELIST=`zipinfo -1 "$1" | grep -E '\.xml|\.html|\.xhtml' |sort`
    TEXT="$TEXT `unzip -caa "$1" "$FILE" | html2text -width $COLS`"
echo "$TEXT" | $PAGER

Which on my screen generates:


My additions to the script are to

  • Rely on your $PAGER in the final line,
  • Add in support for xhtml files, because the epub I downloaded to test it used xhtml 🙄 , and
  • Allow you to pick the width of your terminal, or leave it blank to use the full available width.

Of course, like Anders mentioned, this relies on both unzip and html2text, although the latter could be substituted with another tool, if you prefer it.

And it needs a lot of work. The ultimate effect is the “wall of text,” which I personally despise. As you might notice from my short paragraphs on this blog. 😐

And some better formatting would be nice, as well as some trapping for the leftover HTML that seems to have crept into the display at the top and elsewhere.

But not bad overall. I still count a neverending “Hello World” on my C64 as my greatest programming achievement, but this will do for my contribution. You have my permission to add yours. 😉

epub2pdf: Proof of the viability of Java-based applications

I joke when I say that. A long time ago I was in a rather terse forum “conversation” with a person who insisted Java was the only negotiable programming language because it was cross-platform.

Of course, as a proponent of underpowered hardware, my reply was that I’d rather be beaten about the head and shoulders with a dead fish than suffer too many Java-based applications … cross-platform be darned. 🙄

I don’t hold anything against Java, if that’s your gig. I usually don’t hold anything against anything, because having the choice is the most important part to me.

And now having made all those disclaimers in quick succession, I can offer you a glimpse of the end product of epub2pdf.


It probably doesn’t need said any more, but epub2pdf is apparently a Java program, and will run on anything that you can squeeze the runtime environment into … be that Windows *, Mac OS*, Linux or what have you.

And by all accounts, it does a pretty good job. I’m sure there are PDF-o-philes out there, like there are audiophiles, who can tell me whether or not epub2pdf’s end product is worth a darn. In my book, it’s acceptable.

As far as options go, you’ll have to dig around in epub2pdf’s documentation to find all the tweaks you’re after. By default, epub2pdf dumped the output in my home directory, named the same as the epub.

And I hesitate to say it, but I wonder if epub2pdf isn’t a bit slower than some other tools, being Java-based. I know, I’m an uneducated heel and I have no proof of the insinuation, but over two minutes on a dual-core machine just to convert one document seems … lengthy. I’m sorry. I’m speaking out loud again. 😳

I do know that I would be shy about using this on a machine much older than this dual-core, because I have a feeling performance would drop off exponentially. Just my hunch though.

All of that does not detract from the point that epub2pdf works, works well, and will probably work on your machine too, no matter what it is. So is it proof of the viability of Java-based applications?

Oh heck, I don’t know. 😐