How to fix font size in ePub for Kobo eReader

Very late blogging for today for a sick person like me.

Background: (Feel free to skip it :P)

A few days ago, I managed to get a Kobo eReader for my trip. I might be weird because I don’t want the iPad. I think that it’s too heavy and I only need an ebook reader, plus I have an iPhone 3G!

I have a few pdf files that I like to read for ages but I couldn’t do it because I don’t like reading documents on my laptop. I found that it’s very hard. I have been hunting around for the ebook reader and I found a few cheap ones that does what it supposed to, 2 from OfficeWorks and Kobo.

But I went for Kobo, not because it’s the most expensive one but because it supports both PDF and ePub.

However, most ebook reader can only display PDF as it is – no changing font face and font size etc. So I decided to convert my PDF to ePub using Calibe.

Problem: (Continue here :))

Everything works well for the past few days until I discovered that Kobo has a problem with changing font size for ePub documents because of the css file inside it.

I experimented with removing the css file inside ePub and it works. But I have so many files to process. What did I do? —- of course, I wrote a script —-

Calibre Library Anatomy:

The Calibre Library structure is

– Root

— Author1

— Book1

—- Book1.epub

— Author2

— Book2a

—- Book2a.epub

—Book2b

—- Book2b.epub

(I hope you will get some ideas here)

The script basically

1. Loop through each author folders

2. Loop through each book

3. Unzip each ePub file

4. Remove the css file

5. Zip the ePub file back

The script is written as bash script – Sorry I’m a Mac user ūüôā

Note: sorry for the indentation ūüė¶

#!/bin/bash
######################################
# author: Ploy
# date: Jun 15, 2010
# purpose: to remove CSS files from ePub files
# version: beta
#¬†disclaimer:¬†no¬†warranty¬†–¬†just¬†experimenting
######################################
echo¬†“Removing¬†CSS¬†Files¬†from¬†ePub files”
echo¬†“A¬†quick¬†fix¬†for¬†text¬†resizing¬†in¬†an¬†ebook¬†reader”

# —— EDIT ME ——-
ARCHIVE_DIR=”/Users/ME/CalibreLIBFOLDER”

cd $ARCHIVE_DIR

#loop through each author dir
for author in *
do
echo¬†“$author”

#loop through each book dir
if¬†[¬†-d¬†“$author”¬†]¬†;¬†then
cd¬†“$author”
for book in *
do
if¬†[¬†-d¬†“$book”¬†]¬†;¬†then
cd¬†“$book”
for epub in *.epub
do
echo¬†“Processing…¬†$epub”
unzip¬†-oq¬†“$epub”¬†-d¬†“$epub.unzipped”
cd¬†“$epub.unzipped”
rm -rf *.css
zip¬†-rq¬†“$epub”¬†*
mv¬†-f¬†“$epub”¬†../
cd ..
rm -rf *.unzipped
echo¬†“Finish¬†Processing…¬†$epub”
done
cd ..
fi
done
fi
echo¬†“————–”
cd $ARCHIVE_DIR
done
exit 0