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

About these ads

5 Responses to How to fix font size in ePub for Kobo eReader

  1. Jerimiah says:

    Cool. I’m planning on getting the Kobo too. I’l be running the script in linux though – same thing.

  2. Ploy says:

    Let me know how you go :) I hope it will work well for you too

  3. tam says:

    Is this still true with the latest Calibre? I actually use Calibre to fix epub’s with a hard-coded font-size css tag, for the iPad Stanza app.

  4. Ploy says:

    @tam – according to Kobo firmware release, they said that the the font size should be fixed with the update.

  5. SBomb says:

    The above script didn’t work for me, the following did – running OS X 10.6.7, thanks Ploy for 99.999% of the work (quotes may need to be converted if pasting into a script fwiw):

    #!/bin/bash
    ######################################
    # author: Ploy
    # edited by SJB – many thanks to Ploy for making this possible!
    # 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/bishop/CalibreLibrary”

    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”
    #changed by SJB
    find . -name \*.css | xargs rm -f
    #done SJB changes
    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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: